-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.java
More file actions
51 lines (42 loc) · 1.04 KB
/
Copy pathPlayer.java
File metadata and controls
51 lines (42 loc) · 1.04 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
import java.util.ArrayList;
public class Player {
String name;
int score;
ArrayList<Card> cards;
public Player(String name){
this.name = name;
this.score = 0;
cards = new ArrayList<>();
}
public boolean holdAce(){
for (int i = 0; i < cards.size(); i++){
if (cards.get(i).getNum() == 11){
return true;
}
}
return false;
}
public ArrayList<Card> getCards(){
return cards;
}
public int getScore(){
return this.score;
}
public String getName(){
return this.name;
}
public void addCard(Card card){
cards.add(card);
this.score += card.getNum();
}
public void noCards(){
cards.clear();
}
public void displayCards(){
System.out.println(name + " has:\n");
for (int i = 0; i < this.cards.size(); i++){
System.out.println(this.cards.get(i));
}
System.out.println(name + "'s score is " + this.score + "\n");
}
}