Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PetalGame
- {
- private int d1;
- private int d2;
- private int d3;
- private int d4;
- private int d5;
- public PetalGame(int inD1, int inD2, int inD3, int inD4, int inD5)
- {
- d1 = inD1;
- d2 = inD2;
- d3 = inD3;
- d4 = inD4;
- d5 = inD5;
- }
- public int rollDice()
- {
- return (int) ((Math.random() * 6) + 1);
- }
- public void calculateDice()
- {
- d1 = rollDice();
- d2 = rollDice();
- d3 = rollDice();
- d4 = rollDice();
- d5 = rollDice();
- }
- public int calculateAllPetals()
- {
- int totalPetals = 0;
- totalPetals += dicePoints(d1);
- totalPetals += dicePoints(d2);
- totalPetals += dicePoints(d3);
- totalPetals += dicePoints(d4);
- totalPetals += dicePoints(d5);
- return totalPetals;
- }
- public int dicePoints(int diceRoll)
- {
- if(diceRoll==3||diceRoll==5)
- return diceRoll-1;
- else
- return 0;
- }
- public void printDiceRolles()
- {
- System.out.println("Dice 1: " + d1);
- System.out.println("Dice 2: " + d2);
- System.out.println("Dice 3: " + d3);
- System.out.println("Dice 4: " + d4);
- System.out.println("Dice 5: " + d5);
- }
- public void printPetals()
- {
- System.out.println("Points: " + calculateAllPetals());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement