-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorldPlayer.cpp
More file actions
30 lines (30 loc) · 779 Bytes
/
WorldPlayer.cpp
File metadata and controls
30 lines (30 loc) · 779 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
#include "WorldPlayer.h"
WorldPlayer::WorldPlayer(std::vector <std::string> &name){
for(unsigned int i=0;i<name.size();++i){
Player player(name.at(i));
players_.push_back(player);
}
}
bool WorldPlayer::AddPlayer(const Player& player){
if(players_.size()<4){
players_.push_back(player);
return true;
} else {
return false;
}
}
int WorldPlayer::numBankrupt() const {
int n=0;
for (unsigned int i = 0; i < players_.size(); ++i) {
if (players_[i].money() < 0){
++n;
}
}
return n;
}
std::ostream& operator<<(std::ostream &os, const WorldPlayer &worldPlayer){
for (unsigned int i = 0; i < worldPlayer.players_.size(); ++i) {
os << worldPlayer[i];
}
return os;
}