-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathContinent.cpp
More file actions
68 lines (58 loc) · 1.07 KB
/
Copy pathContinent.cpp
File metadata and controls
68 lines (58 loc) · 1.07 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
62
63
64
65
66
67
68
#include "Continent.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
Continent::Continent() //contructor
{
name = "";
armyNum = 0;
numCountries = 0;
}
Continent::Continent(string n, int number) //overloading (if the name and army number is given)
{
name = n;
armyNum = number;
numCountries = 0;
}
string Continent::getName()
{
return name;
}
int Continent::getArmyNum()
{
return armyNum;
}
int Continent::getNumCountries(){
return numCountries;
}
void Continent::addCountry(Country* newTerritory) {
countryArray[numCountries] = newTerritory;
numCountries++;
}
Player* Continent::getOwningPlayer() {
if (this->numCountries > 0) {
Player* owner = this->countryArray[0]->occupiedBy;
for (int i = 1; i < this->numCountries; i++) {
if (owner != this->countryArray[i]->occupiedBy) {
return NULL;
}
}
return owner;
}
else {
return NULL;
}
}
string Continent::getOwnerName() {
Player* owner = this->getOwningPlayer();
if (owner == NULL) {
return "nobody";
}
else {
return owner->name;
}
}
Continent::~Continent()
{
}