diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..bfbeb0d --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/devcontainers/java:21" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..add4f4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file diff --git a/Dice.java b/Dice.java new file mode 100644 index 0000000..5266834 --- /dev/null +++ b/Dice.java @@ -0,0 +1,25 @@ +import java.util.Random; + +public class Dice { + + private int id; + private int value; + + public Dice(int id) { + this.id = id; + rollTheDice(); + } + + public int getId() { + return id; + } + + public int getValue() { + return value; + } + + public void rollTheDice() { + Random random = new Random(); + value = random.nextInt(6) + 1; + } +} diff --git a/Exercise.java b/Exercise.java index 3c092f9..40bbccd 100644 --- a/Exercise.java +++ b/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()); + } } }