forked from tlu21545/Java_Challenge_2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainClass.java
More file actions
20 lines (20 loc) · 841 Bytes
/
mainClass.java
File metadata and controls
20 lines (20 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class mainClass{
public static void main(String[] args){
//Creates an array of dices
Die dice[] = new Die[50];
//variable storing the total dice value
int totalDiceValue = 0;
//for loop that initalizes each index in the die array, rolls it, and prints it out in the terminal.
for(int i = 0; i<50; i++){
dice[i] = new Die(6);
dice[i].roll();
System.out.println("Roll " + (i+1) + ": " + dice[i].readLastRoll());
}
//gets the last roll of each die in the array and adds it to totalDiceValue
for(int i = 0; i<50; i++){
totalDiceValue += dice[i].readLastRoll();
}
//prints out totalDiceValue
System.out.println("Total value of the " + (dice.length) + " rolls is " + totalDiceValue);
}
}