-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeam.cpp
74 lines (56 loc) · 2.05 KB
/
Team.cpp
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
69
70
71
72
73
74
#include "Team.h"
using namespace std;
Team::Team(string s)
{
color = s;
if (s == "Red")
players = new Player[11] {Player("Marios", male, 30), Player("Tsikilis", male, 34),Player("Nikoleta", female, 23),Player("Chambos", male, 30),Player("Gogo", female, 27),Player("Konstantinos", male, 52),Player("Giorgos", male, 36),Player("Ilektra", female, 28), Player("Glossidis", male, 24),Player("Savvas", male, 28), Player("Tzortzis",male,25)};
else
players = new Player[11] {Player("Selim", male, 39), Player("Nikol", female, 22), Player("Timoleon", male, 28), Player("Vasilis", male, 26), Player("Magky", female, 35), Player("Argyris", male, 25), Player("Maia", female, 45),Player("Symeonidis", male, 24), Player("Christina", female, 20),Player("Seferidis", male, 23), Player("Argyroudi", female, 21)};
}
int Team::getNumberOfPlayers()
{
int result = 0;
for (int i = 0; i < 11; i++)
if (players[i].getAge() != 0)
result++;
return result;
}
void Team::setCandidate(string player){
for (int i = 0; i < 11; i++){
if (player == players[i].getName()){
players[i].setCandidate(true);
players[i].status();
break;
}
}
}
void Team::removePlayer(string name)
{
int index = -1;
Player p;
for (int i = 0; i < 11; i++){
if (players[i].getName() == name){
index = i;
break;
}
}
if (index != -1){
players[index] = p;
cout << "Player with name " << name << " is removed." << endl;
}
else
cout << "Player with name " << name << " is not available." << endl;
}
void Team::status(bool playerInformation)
{
cout << "Color: " << color << endl;
if (playerInformation)
{
cout << endl << "Players:" << endl;
for (int playerIndex = 0; playerIndex < 11; playerIndex++)
if (players[playerIndex].getAge() != 0)
players[playerIndex].status();
}
cout << endl << endl;
}