Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"image": "mcr.microsoft.com/devcontainers/java:21"
}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"vscjava.vscode-java-pack"
]
}
20 changes: 20 additions & 0 deletions DiceCup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.ArrayList;

public class DiceCup {

public void rollTheDices(ArrayList<Dice> dices) {
for (int i = 0; i < dices.size(); i++) {
Dice dice = dices.get(i);
dice.rollTheDice();
System.out.println(dice.getId() + " - " + dice.getValue());
}
}

public void rollTheDices(Dice[] dices) {
for (int i = 0; i < dices.length; i++) {
Dice dice = dices[i];
dice.rollTheDice();
System.out.println(dice.getId() + " - " + dice.getValue());
}
}
}
17 changes: 16 additions & 1 deletion Exercise.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
import java.util.ArrayList;

public class Exercise {

public static void main(String[] args) {
// implement exercise here
ArrayList<Dice> dices = new ArrayList<>();

for (int i = 1; i <= 5; i++) {
Dice dice = new Dice(i);
dices.add(dice);
}

DiceCup diceCup = new DiceCup();

System.out.println("ID - Wuerfelwert");
for (int i = 1; i <= 5; i++) {
System.out.println("Wurf " + i);
diceCup.rollTheDices(dices);
}
}
}
Loading