Skip to content

Commit 92a3ef8

Browse files
committed
implement solution
1 parent 87c564a commit 92a3ef8

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

DiceCup.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.ArrayList;
2+
3+
public class DiceCup {
4+
5+
public void rollTheDices(ArrayList<Dice> dices) {
6+
for (int i = 0; i < dices.size(); i++) {
7+
Dice dice = dices.get(i);
8+
dice.rollTheDice();
9+
System.out.println(dice.getId() + " - " + dice.getValue());
10+
}
11+
}
12+
13+
public void rollTheDices(Dice[] dices) {
14+
for (int i = 0; i < dices.length; i++) {
15+
Dice dice = dices[i];
16+
dice.rollTheDice();
17+
System.out.println(dice.getId() + " - " + dice.getValue());
18+
}
19+
}
20+
21+
}

Exercise.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
import java.util.ArrayList;
2+
13
public class Exercise {
24

35
public static void main(String[] args) {
4-
// implement exercise here
6+
ArrayList<Dice> dices = new ArrayList<>();
7+
8+
for (int i = 1; i <= 5; i++) {
9+
Dice dice = new Dice(i);
10+
dices.add(dice);
11+
}
12+
13+
DiceCup diceCup = new DiceCup();
14+
15+
System.out.println("ID - Wuerfelwert");
16+
for (int i = 1; i <= 5; i++) {
17+
System.out.println("Wurf " + i);
18+
diceCup.rollTheDices(dices);
19+
}
520
}
621
}

0 commit comments

Comments
 (0)