We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0fced0c commit fdc5716Copy full SHA for fdc5716
2 files changed
Dice.java
@@ -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
@@ -1,6 +1,12 @@
public class Exercise {
public static void main(String[] args) {
- // implement exercise here
+ Dice dice = new Dice(1);
+ System.out.println("ID - Wuerfelwert");
+ for (int i = 1; i <= 5; i++) {
+ dice.rollTheDice();
+ System.out.println(dice.getId() + " - " + dice.getValue());
}
0 commit comments