Skip to content

Commit fdc5716

Browse files
committed
implement solution
1 parent 0fced0c commit fdc5716

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Dice.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Random;
2+
3+
public class Dice {
4+
5+
private int id;
6+
private int value;
7+
8+
public Dice(int id) {
9+
this.id = id;
10+
rollTheDice();
11+
}
12+
13+
public int getId() {
14+
return id;
15+
}
16+
17+
public int getValue() {
18+
return value;
19+
}
20+
21+
public void rollTheDice() {
22+
Random random = new Random();
23+
value = random.nextInt(6) + 1;
24+
}
25+
}

Exercise.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
public class Exercise {
22

33
public static void main(String[] args) {
4-
// implement exercise here
4+
Dice dice = new Dice(1);
5+
6+
System.out.println("ID - Wuerfelwert");
7+
for (int i = 1; i <= 5; i++) {
8+
dice.rollTheDice();
9+
System.out.println(dice.getId() + " - " + dice.getValue());
10+
}
511
}
612
}

0 commit comments

Comments
 (0)