-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.java
More file actions
56 lines (46 loc) · 1.13 KB
/
Player.java
File metadata and controls
56 lines (46 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
public class Player {
private int chipStack;
private int bet;
public Player(int chipStack) {
this.chipStack = chipStack;
this.bet = 0;
}
public int getBet() {
return bet;
}
public int getChipStack() {
return chipStack;
}
public boolean makeBet(int bet) {
boolean madeBet = false;
if (chipStack >= bet) {
this.bet = bet;
this.chipStack -= bet;
madeBet = true;
} else {
System.out.println("You don't have enough chips to make this bet!");
}
return madeBet;
}
public void winBet(int bet) {
this.chipStack += bet * 2;
resetBet();
}
public void loseBet() {
if (chipStack == 0) {
System.out.println("You are out of chips. The house always wins >:)");
}
resetBet();
}
public void pushBet(int bet) {
this.chipStack += bet;
resetBet();
}
public void blackjack(int bet) {
this.chipStack += bet + (bet * 1.5);
resetBet();
}
public void resetBet() {
this.bet = 0;
}
}