|
@@ -12,6 +12,7 @@ public class HigherCards extends CardGame implements Gambling{
|
12
|
12
|
boolean playAgain = true;
|
13
|
13
|
int bet;
|
14
|
14
|
int player,croupier;
|
|
15
|
+ int totalChips,wageAmount;
|
15
|
16
|
public void setBet(int bet) {
|
16
|
17
|
this.bet = bet;
|
17
|
18
|
}
|
|
@@ -24,20 +25,16 @@ public class HigherCards extends CardGame implements Gambling{
|
24
|
25
|
while (playAgain) {
|
25
|
26
|
deck.shuffle();
|
26
|
27
|
int wageAmount = wageMoney();
|
|
28
|
+ aConsole.println("You Got :");
|
27
|
29
|
playerDrawingCard();
|
|
30
|
+ aConsole.println("House Got :");
|
28
|
31
|
houseDrawingCard();
|
29
|
|
- int totalChips = aPlayer.getTotalChips();
|
30
|
|
- findWinner(player, croupier, wageAmount);
|
31
|
|
- if (aPlayer.getTotalChips() > totalChips) {
|
32
|
|
- aConsole.println("Congrats ! You Won ");
|
33
|
|
- } else {
|
34
|
|
- aConsole.println("You Lose");
|
35
|
|
- }
|
36
|
|
- aConsole.println("Your current available Chips");
|
37
|
|
- aConsole.println(aPlayer.getTotalChips().toString());
|
|
32
|
+ findWinner(wageAmount,player, croupier);
|
|
33
|
+ aConsole.println("Your current available Chips %d",aPlayer.getTotalChips());
|
38
|
34
|
repeat();
|
39
|
35
|
}
|
40
|
36
|
}
|
|
37
|
+
|
41
|
38
|
public void repeat()
|
42
|
39
|
{
|
43
|
40
|
if((aPlayer.getTotalChips() == 0) )
|
|
@@ -55,44 +52,33 @@ public class HigherCards extends CardGame implements Gambling{
|
55
|
52
|
Card acard = deck.draw();
|
56
|
53
|
Rank rank = acard.getRank();
|
57
|
54
|
player = rank.getValue();
|
58
|
|
- String playervalueString=rank.toString();
|
59
|
|
- String playerFace=rank.getFaceValue();
|
60
|
|
-
|
61
|
55
|
Suit suit = acard.getSuit();
|
62
|
|
- String suitSymbol=suit.getsuitSymbol();
|
63
|
|
- String suitString = suit.toString();
|
64
|
|
-
|
65
|
|
- aConsole.println("You got :%s of %s",playervalueString,suitString);
|
66
|
|
- printCard(suitSymbol,playerFace);
|
|
56
|
+ printCard(suit.getsuitSymbol(),rank.getFaceValue());
|
67
|
57
|
}
|
68
|
58
|
public void houseDrawingCard()
|
69
|
59
|
{
|
70
|
60
|
Card acard2 = deck.draw();
|
71
|
61
|
Rank rank2 = acard2.getRank();
|
72
|
62
|
croupier = rank2.getValue();
|
73
|
|
- String playervalueString2=rank2.toString();
|
74
|
|
- String playerFace2=rank2.getFaceValue();
|
75
|
|
-
|
76
|
63
|
Suit suit2 = acard2.getSuit();
|
77
|
|
- String suitString2 = suit2.toString();
|
78
|
|
- String suitSymbol2=suit2.getsuitSymbol();
|
79
|
|
-
|
80
|
|
- aConsole.println("House got :%s of %s",playervalueString2,suitString2);
|
81
|
|
- printCard(suitSymbol2,playerFace2);
|
|
64
|
+ printCard(suit2.getsuitSymbol(),rank2.getFaceValue());
|
82
|
65
|
}
|
83
|
66
|
|
84
|
|
- public void findWinner(int player,int croupier,int wageAmount)
|
|
67
|
+ public void findWinner(int wageAmount,int player,int croupier)
|
85
|
68
|
{
|
86
|
69
|
if (player > croupier) {
|
|
70
|
+ aConsole.println("Congrats ! You Won ");
|
87
|
71
|
int[] change = {aPlayer.getTally()[0] + 1, aPlayer.getTally()[1]};
|
88
|
72
|
aPlayer.setTally(change);
|
89
|
73
|
aPlayer.setTotalChips(aPlayer.getTotalChips()+ wageAmount);
|
90
|
74
|
}
|
91
|
75
|
else {
|
|
76
|
+ aConsole.println("You Lose");
|
92
|
77
|
int[] change = {aPlayer.getTally()[0], aPlayer.getTally()[1] + 1};
|
93
|
78
|
aPlayer.setTally(change);
|
94
|
79
|
aPlayer.setTotalChips(aPlayer.getTotalChips()- wageAmount);
|
95
|
80
|
}
|
|
81
|
+
|
96
|
82
|
aConsole.println("Your current Win/Loss Ratio is " + aPlayer.getTally()[0] + "-" + aPlayer.getTally()[1] + "\n");
|
97
|
83
|
}
|
98
|
84
|
|