-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
117 lines (90 loc) · 2.06 KB
/
Player.java
File metadata and controls
117 lines (90 loc) · 2.06 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package Blackjack.src.main.java.model;
/**
* Represents a Black Jack player
*/
public class Player
{
private String name;
private int funds;
private Hand[] currentCards = new Hand[1];
private int handCount = 1;
/**
* Creates a player
* @param String name, int funds
*/
public Player(String name, int funds){
this.name = name;
this.funds = funds;
Hand hand = new Hand(5);
currentCards[0] = hand;
}
/**
* Creates a player
* @param String name
*/
public Player(String name){
this.name = name;
this.funds = 1000;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getFunds() {
return funds;
}
public void setFunds(int funds) {
this.funds = funds;
}
public int getHandCount() {
return handCount;
}
public void setHandCount(int handCount) {
this.handCount = handCount;
}
public Hand[] getCurrentCards() {
return currentCards;
}
public void setCurrentCards(Hand[] currentCards) {
this.currentCards = currentCards;
}
/**
* Player Chooses to Double Down. 1 card added to hand and bet is doubled.
* @param int handNumber
*/
public void doubleDown(int handNumber){
int bet = currentCards[handNumber].getBet();
currentCards[handNumber].setBet(bet*2);
currentCards[handNumber].addCard(BlackJackGame.deck.deal());
}
/**
* Player chooses to split
*/
public void split(int handNumber) {
int bet = currentCards[handNumber].getBet();
Hand[] temp = new Hand[handCount+1];
handCount++;
for(int i = 0 ; i < handCount-1 ; i++)
temp[i] = currentCards[i];
temp[handNumber+1].addCard(temp[handNumber].getCard(1));
temp[handNumber].setCard(1,BlackJackGame.deck.deal());
temp[handNumber+1].addCard(BlackJackGame.deck.deal());
temp[handNumber+1].setBet(bet);
currentCards = temp;
}
/**
* Player chooses to hit.
*/
public void hit(int handNumber) {
Card card = BlackJackGame.deck.deal();
currentCards[handNumber].addCard(card);
}
/**
* Player chooses to Stand
*/
public void stand(int handNumber) {
//turn over
}
}