Assignment 7: Game Wheel reddit
import java.util.ArrayList;
public class Game
{
public static void play(GameWheel g)
{
// Implement the play method here
String s = "";
int sum = 0;
boolean n = true;
ArrayList<String> colors = new ArrayList<String>();
for (int i = 0; i < 3; i++) {
int x = (int)(Math.random() * 20);
int amount = g.getSlice(x).getPrizeAmount();
colors.add(g.getSlice(x).getColor());
s += "Spin " + (i + 1) + " - " + g.getSlice(x) + "\n";
sum += amount;
}
for (int i = 0; i < colors.size() - 1; i++) {
if (colors.get(i).equals(colors.get(i + 1))) {
continue;
} else {
n = false;
}
}
if (n) {
sum *= 2;
System.out.println("Total prize money: $" + sum + "\n");
System.out.println(s);
System.out.println("Three " + colors.get(0) + "s = double your money!");
} else {
System.out.println("Total prize money: $" + sum + "\n");
System.out.println(s);
}
}
}
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line