-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGamer.java
61 lines (50 loc) · 1.05 KB
/
Gamer.java
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
package BlackJack;
import java.util.List;
import java.util.ArrayList;
public class Gamer implements Player {
private List<Card> cards;
private boolean turn;
private String name;
public Gamer(String name) {
cards = new ArrayList<>();
this.name = name;
}
@Override
public void receiveCard(Card card) {
this.cards.add(card);
this.showCards();
}
// 카드를 더 뽑을지 정하기위해 현재 카드들을 확인할수 있도록 하는 메서드
@Override
public void showCards() {
StringBuilder sb = new StringBuilder();
sb.append("현재 보유 카드 목록 \n");
for(Card card: cards) {
sb.append(card.toString());
sb.append("\n");
}
System.out.println(sb.toString());
}
public List<Card> openCards() {
return this.cards;
}
@Override
public void turnOff() {
this.setTurn(false);
}
@Override
public void turnOn() {
this.setTurn(true);
}
@Override
public boolean isTurn() {
return this.turn;
}
private void setTurn(boolean turn) {
this.turn = turn;
}
@Override
public String getName() {
return this.name;
}
}