PR2-YahtzeeStarWarsSpecial/src/domain/Dice.java

39 lines
899 B
Java

package domain;
import java.lang.Math;
public class Dice {
private int diceNumber;
private String savedGamemode;
public Dice(String gamemode) {
this.savedGamemode = gamemode;
if (gamemode.equals("Normal"))
this.diceNumber = ((int) (Math.random() * 6)) + 1;
else if (gamemode.equals("Special8"))
this.diceNumber = ((int) (Math.random() * 8)) + 1;
}
public Dice(String gamemode, int diceNumber) {
this.savedGamemode = gamemode;
this.diceNumber = diceNumber;
}
public void rerollDice() {
if (this.savedGamemode.equals("Normal"))
this.diceNumber = ((int) (Math.random() * 6)) + 1;
else if (this.savedGamemode.equals("Special8"))
this.diceNumber = ((int) (Math.random() * 8)) + 1;
}
public int getDiceNumber() {
return this.diceNumber;
}
}