View difference between Paste ID: VKmifnKc and ak05CSbw
SHOW: | | - or go back to the newest paste.
1
public class PetalGame
2
{
3
	private int d1;
4
	private int d2;
5
	private int d3;
6
	private int d4;
7
	private int d5;
8
9
	public PetalGame(int inD1, int inD2, int inD3, int inD4, int inD5)
10
	{
11
	    d1 = inD1;
12
	    d2 = inD2;
13
	    d3 = inD3;
14
	    d4 = inD4;
15
	    d5 = inD5;
16
	}
17
18
	public int rollDice()
19
	{
20
	    return (int) ((Math.random() * 6) + 1);
21
	}
22
23-
	public void printDice()
23+
	public void calculateDice()
24
	{
25
	    d1 = rollDice();
26
	    d2 = rollDice();
27
	    d3 = rollDice();
28
	    d4 = rollDice();
29
	    d5 = rollDice();
30-
	
30+
31-
	    System.out.println("You rolled the following: " + d1 + ", " 
31+
32-
	    +  d2 + ", " +  d3 + ", " +  d4 + ", " +  d5);
32+
33
	{
34
		int totalPetals = 0;
35
		
36
		totalPetals += dicePoints(d1);
37
		totalPetals += dicePoints(d2);
38
		totalPetals += dicePoints(d3);
39-
	    if (d1 == 3 || d1 == 5)
39+
		totalPetals += dicePoints(d4);
40-
	    	totalPetals += d1 - 1;
40+
		totalPetals += dicePoints(d5);
41-
	    if (d2 == 3 || d2 == 5)
41+
42-
	    	totalPetals += d2 - 1;
42+
		return totalPetals;
43-
	    if (d3 == 3 || d3 == 5)
43+
44-
	    	totalPetals += d3 - 1;
44+
45-
	    if (d4 == 3 || d4 == 5)
45+
	public int dicePoints(int diceRoll)
46-
	    	totalPetals += d4 - 1;
46+
47-
	    if (d5 == 3 || d5 == 5)
47+
		if(diceRoll==3||diceRoll==5)
48-
	    	totalPetals += d5 - 1;
48+
			return diceRoll-1;
49-
	    
49+
		else
50-
	    return totalPetals;
50+
			return 0;
51
	}
52
53
	public void printDiceRolles()
54
	{
55
		System.out.println("Dice 1: " + d1);
56
		System.out.println("Dice 2: " + d2);
57
		System.out.println("Dice 3: " + d3);
58
		System.out.println("Dice 4: " + d4);
59
		System.out.println("Dice 5: " + d5);
60
	}
61
62
	public void printPetals()
63
	{
64
		System.out.println("Points: " + calculateAllPetals());
65
	}
66
}