-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
58 lines (45 loc) · 1.46 KB
/
Copy pathPlayer.java
File metadata and controls
58 lines (45 loc) · 1.46 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
import java.util.ArrayList;
public class Player {
//player has hand of 4 Cards and Bank
private ArrayList<Card> hand = new ArrayList<>();
private ArrayList<Card> bank = new ArrayList<>();
//default constructor
public Player() {}
//adds a card to the player bank
public void addToBank(Card card) {
bank.add(card);
}
//adds card to player hand
public void addToHand(Card card) {
//checks if max hand size is reached (4)
if (hand.size() >= 4){
System.out.println("Max hand size reached!");
return;
}
hand.add(card);
}
public void removeFromHand(Card card) {
hand.remove(card);
}
public ArrayList getHand() {
return hand;
}
//gets players hand after the hidden cards have been chosen
public void getHiddenHand(int firstHidden, int secondHidden) {
System.out.println("[");
for (int i = 0; i < 4; i++) {
//checks if card was chosen to be hidden, and hides it if it is hidden.
if (i == firstHidden-1 || i == secondHidden-1) { System.out.println("-"); }
else { System.out.println(hand.get(i)); }
}
System.out.println("]");
}
//adds up score from bank to get final score
public double getScore() {
double score = 0.0;
for (int i = 0; i < bank.size(); i++) {
score += bank.get(i).getPoint_value();
}
return score;
}
}