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"
]
}
2 changes: 1 addition & 1 deletion Dice.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class Dice {

private int id;
private int value;
protected int value;

public Dice(int id) {
this.id = id;
Expand Down
34 changes: 31 additions & 3 deletions DiceGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,38 @@ public void start() {
}

private void move(Player player) {
dices.add(new Dice(1));
dices.add(new Dice(2));
dices.add(new Dice(3));
int input;
System.out.println(player.getName() + " hat aktuell " + player.getScore() + " Punkte");
if (player.getSpecialAvailable()) {
System.out.print(
player.getName() + ", moechtest Du einmalig Spezialwuerfel verwenden (1=ja, 2=nein)?: ");
input = scanner.nextInt();
if (input == 1) {
System.out.print(
player.getName()
+ ", welche Spezialwuerfel moechtest Du verwenden (1=4-5-6-Wuerfel,"
+ " 2=1-2-3-Wuerfel)?: ");
input = scanner.nextInt();
if (input == 1) {
dices.add(new HighValueDice(4));
dices.add(new HighValueDice(5));
dices.add(new HighValueDice(6));
} else {
dices.add(new LowValueDice(7));
dices.add(new LowValueDice(8));
dices.add(new LowValueDice(9));
}
player.setSpecialAvailable(false);
} else {
dices.add(new Dice(1));
dices.add(new Dice(2));
dices.add(new Dice(3));
}
} else {
dices.add(new Dice(1));
dices.add(new Dice(2));
dices.add(new Dice(3));
}
System.out.print(player.getName() + ", moechtest Du wuerfeln (true, false)?: ");
if (scanner.nextBoolean()) {
diceCup.rollTheDices(dices);
Expand Down
13 changes: 13 additions & 0 deletions HighValueDice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.Random;

public class HighValueDice extends Dice {

public HighValueDice(int id) {
super(id);
}

public void rollTheDice() {
Random random = new Random();
value = random.nextInt(3) + 4;
}
}
13 changes: 13 additions & 0 deletions LowValueDice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.Random;

public class LowValueDice extends Dice {

public LowValueDice(int id) {
super(id);
}

public void rollTheDice() {
Random random = new Random();
value = random.nextInt(3) + 1;
}
}
11 changes: 11 additions & 0 deletions Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ public class Player {
private String name;
private int score;
private boolean isActive;
private boolean specialAvailable;

public Player(String name) {
this.name = name;
isActive = true;
specialAvailable = true;
}

public String getName() {
Expand All @@ -27,4 +30,12 @@ public boolean isActive() {
public void setActive(boolean isActive) {
this.isActive = isActive;
}

public boolean getSpecialAvailable() {
return specialAvailable;
}

public void setSpecialAvailable(boolean specialAvailable) {
this.specialAvailable = specialAvailable;
}
}
Loading