-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
97 lines (60 loc) · 1.64 KB
/
Copy pathPlayer.java
File metadata and controls
97 lines (60 loc) · 1.64 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Max Chwa
* Player.java - A template for a Player of video poker.
*/
import java.util.ArrayList;
public class Player {
private ArrayList<Card> hand; // the player's cards
private double bankroll = 50;
private double bet;
private boolean betSizeValidity;
public Player(){
// create a player here
bankroll = 50;
hand = new ArrayList<>();
bet = 0;
betSizeValidity = false;
}
public void addCard(Card c){
hand.add(c);
// add the card c to the player's hand
}
public void removeCard(Card c){
for (int i = 0; i < 5; i++){
if (hand.get(i).compareTo(c) == 0) {
hand.remove(i);
break;
}
}
// remove the card c from the player's hand
}
public void removeIt(int s) {
hand.remove(s - 1);
}
public void bets(double amt) {
// player makes a bet
if (amt > bankroll || amt < 1 || amt > 5) {
betSizeValidity = false;
} else {
betSizeValidity = true;
bet = amt;
}
}
public void winnings(double odds){
//adjust bankroll if player wins
bankroll = bankroll - bet + bet * odds;
bet = 0;
}
public double getBankroll(){
// return current balance of bankroll
return bankroll;
}
public ArrayList<Card> getHand() {
return hand;
}
public boolean getBetSizeValidity() {
return betSizeValidity;
}
public int getHandLength() {
return hand.size();
}
}