|
@@ -32,14 +32,20 @@ public class Craps extends DiceGame implements Gamble {
|
32
|
32
|
}
|
33
|
33
|
|
34
|
34
|
public void gamePlay(){
|
35
|
|
- System.out.println("What would you like to bet? Min bet is: " + minBet);
|
|
35
|
+ System.out.println("What would you like to bet? Min bet is: $" + minBet);
|
36
|
36
|
int amount = scanner.nextInt();
|
37
|
|
- System.out.println("Are you ready to roll?");
|
|
37
|
+ if (amount<minBet){
|
|
38
|
+ System.out.println("Sorry but the minimum bet is $"+minBet);
|
|
39
|
+ gamePlay();
|
|
40
|
+ }
|
|
41
|
+ crapsPlayer.setInitialBet(amount);
|
|
42
|
+ System.out.println("Are you ready to roll? yes or no");
|
38
|
43
|
String response = scanner.next();
|
39
|
44
|
if(response.equalsIgnoreCase("yes")) {
|
40
|
|
- rollDice();
|
41
|
|
- } else {
|
42
|
|
- System.out.println("ready yet?");
|
|
45
|
+ } else if(response.equalsIgnoreCase("no")) {
|
|
46
|
+ gamePlay();
|
|
47
|
+ } else{
|
|
48
|
+ System.out.println("no valid");
|
43
|
49
|
}
|
44
|
50
|
firstRoll();
|
45
|
51
|
remainingRolls();
|
|
@@ -53,23 +59,23 @@ public class Craps extends DiceGame implements Gamble {
|
53
|
59
|
}
|
54
|
60
|
|
55
|
61
|
public void firstRoll() {
|
56
|
|
- rollDice();
|
57
|
|
- if (rollDice() == 7 || rollDice() == 11) {
|
|
62
|
+ int result = rollDice();
|
|
63
|
+ if (result == 7 || result == 11) {
|
58
|
64
|
win(crapsPlayer);
|
59
|
|
- } else if (rollDice() == 2 || rollDice() == 3 || rollDice() == 12) {
|
|
65
|
+ } else if (result == 2 || result == 3 || result == 12) {
|
60
|
66
|
lose(crapsPlayer);
|
61
|
67
|
} else {
|
62
|
|
- pointer = rollDice();
|
|
68
|
+ pointer = result;
|
63
|
69
|
}
|
64
|
70
|
}
|
65
|
71
|
|
66
|
72
|
public void remainingRolls() {
|
67
|
|
- rollDice();
|
68
|
|
- if (rollDice() == pointer) {
|
|
73
|
+ int result = rollDice();
|
|
74
|
+ if (result == pointer) {
|
69
|
75
|
win(crapsPlayer);
|
70
|
|
- } else if (rollDice() == 7) {
|
|
76
|
+ } else if (result == 7) {
|
71
|
77
|
lose(crapsPlayer);
|
72
|
|
- }
|
|
78
|
+ } else remainingRolls();
|
73
|
79
|
}
|
74
|
80
|
|
75
|
81
|
public int betAmount(int amount, Player player) {
|
|
@@ -82,21 +88,17 @@ public class Craps extends DiceGame implements Gamble {
|
82
|
88
|
}
|
83
|
89
|
|
84
|
90
|
public void win(CrapsPlayers crapsPlayers){
|
85
|
|
- player.setWallet(player.getWallet() + crapsPlayers.getBetPot() * 2);
|
86
|
|
- System.out.println("Congrats! You won: $" + crapsPlayers.getBetPot());
|
87
|
|
- System.out.println("Would you like to play again?");
|
88
|
|
- String response = scanner.next();
|
89
|
|
- if(response.equalsIgnoreCase("yes")) {
|
90
|
|
- start();
|
91
|
|
- } else if(response.equalsIgnoreCase("no")) {
|
92
|
|
- end();
|
93
|
|
- } else {
|
94
|
|
- System.out.println("Sorry I didn't quite get that, try again!");
|
95
|
|
- }
|
|
91
|
+ crapsPlayers.setWallet(crapsPlayers.getWallet() + crapsPlayers.getInitialBet() * 2);
|
|
92
|
+ System.out.println("Congrats! You won: $" + crapsPlayers.getInitialBet());
|
|
93
|
+ playAgain();
|
96
|
94
|
}
|
97
|
95
|
|
98
|
96
|
public void lose(CrapsPlayers crapsPlayers) {
|
99
|
97
|
System.out.println("I'm so sorry, you lose!");
|
|
98
|
+ playAgain();
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ public void playAgain(){
|
100
|
102
|
System.out.println("Would you like to play again?");
|
101
|
103
|
String response = scanner.next();
|
102
|
104
|
if(response.equalsIgnoreCase("yes")) {
|
|
@@ -106,6 +108,7 @@ public class Craps extends DiceGame implements Gamble {
|
106
|
108
|
} else {
|
107
|
109
|
System.out.println("Sorry I didn't quite get that, try again!");
|
108
|
110
|
}
|
|
111
|
+ end();
|
109
|
112
|
}
|
110
|
113
|
|
111
|
114
|
public void distributePot(int amount, Player player) {
|