-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayer.cpp
More file actions
executable file
·48 lines (39 loc) · 862 Bytes
/
Player.cpp
File metadata and controls
executable file
·48 lines (39 loc) · 862 Bytes
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
#include <iostream>
#include "Player.h"
Player::Player(const string &name, const Hand &hand) {
this->name = name;
this->hand = hand;
passCount = 0;
}
string Player::getName() {
/* Returns user name */
return name;
}
Card Player::play() {
/* Returns the last card on hand */
return hand.turn();
}
void Player::win(const vector<Card> &cards) {
/* Adds cards to user's hand */
hand.addCards(cards);
}
int Player::points() {
/* Returns user points */
return hand.cardCount();
}
bool Player::canPlay() {
/* Returns user availability */
return points() > 0;
}
void Player::showHand() {
/* Shows user hand */
cout << name << ": " << hand.asString() << endl;
}
int Player::getPassCount() {
/* Returns user pass count */
return passCount;
}
void Player::pass() {
/* Adds one more pass */
passCount++;
}