Repository navigation
Expand file tree
/
Copy pathPlayer.cpp
More file actions
62 lines (52 loc) · 1.51 KB
/
Copy pathPlayer.cpp
File metadata and controls
62 lines (52 loc) · 1.51 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
59
60
61
#include "Player.h"
using namespace std;
Player::Player() //default constructor
{
vector<string*> territories;
vector<string*> hand;
vector<Order*> orderList;
}
Player::Player(vector<string*> t, vector<string*> h, vector<Order*> o) //constructor with parameters
{
this->territories = t;
this->hand = h;
this->orderList = o;
}
Player::Player(const Player &p) //copy constructor
{
this->territories = p.territories;
this->hand = p.hand;
this->orderList = p.orderList;
}
void Player::toDefend() //returns list of territories to be defended
{
for (int i = 0; i < territories.size(); i++)
{
cout << *territories[i] << "";
}
}
void Player::toAttack() //returns arbitrary list of territories to be attacked
{
vector<string*> tAttack;
string ta1 = "Belgium";
string ta2 = "Norway";
tAttack.push_back(&ta1);
tAttack.push_back(&ta2);
for (int i = 0; i < tAttack.size(); i++)
{
cout << *tAttack[i] << "";
}
}
void Player::issueOrder(string order) //adds new order to the orderList
{
Order *o = new Order(order);
orderList.push_back(o);
}
void Player::printOrderList() //for later display of orderList
{
vector<Order*>::iterator i = orderList.begin();
for (i != orderList.end(); i++)
{
cout << (*i)->getResult() << " ";
}
}