-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiceGame.java
More file actions
32 lines (32 loc) · 1.01 KB
/
Copy pathDiceGame.java
File metadata and controls
32 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//Nancy
import java.util.*;
public class DiceGame
{
public static void main (String [] args){
ArrayList <DieCup> dices = new ArrayList <DieCup> (0);
Scanner scan = new Scanner (System.in);
int ans = 9;
int count = 0;
while (ans != 0){
System.out.println("Please enter a number of dice, or 0 to end the game");
ans = scan.nextInt();
dices.add(new DieCup(ans));
dices.get(count).rollDie(ans);
int [] ret = (dices.get(count).getValues());
for (int x : ret){
System.out.println(x);
}
System.out.println(dices.get(count).toString());
if (dices.get(count).yahtzee()){
System.out.println("Yahtzee!");
}
count++;
}
System.out.println("Second turn:");
if (dices.get(1).yahtzee()){
System.out.println("Yahtzee!");
}
else
System.out.println("No yahtzee.");
}
}