-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clan.h
139 lines (93 loc) · 2.75 KB
/
Clan.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// Created by Tommyisr on 5/7/2018.
//
#ifndef HW1_CLAN_H
#define HW1_CLAN_H
#include <iostream>
#include "treeAVL.h"
#include <stdlib.h>
#include "Player.h"
class Player;
class Clan {
int id;
int numOfPlayers;
int Winner;
int challengesOfBestPlayer;
int indexInHeap;
AVL<class Player>* Players;
public:
Clan() : id(-1), numOfPlayers(0), Winner(1), challengesOfBestPlayer(-1), indexInHeap(0), Players(NULL) {};
Clan(int id) {
this->id=id;
numOfPlayers = 0;
Winner = 1;
challengesOfBestPlayer= -1;
Players = new AVL<Player>;
indexInHeap = 0;
}
~Clan() {
delete Players;
//Players.destroyAVLWithoutRoot();
};
bool isPlayerExist(Player& p);
void addPlayer(Player& p);
AVL<Player > &getPlayers();
void printKeys();
// void deleteKey(int key1, int key2);
int getBestPlayer();
int getID(){ return id;};
void setIndexInHeap(int i);
int getIndexInHeap();
int getNumOfPlayers();
// void substituteTree(AVL<class Players > subTree) {
// (*Players).destroyAVLWithoutRoot();
// //Players=subTree;
// }
int getWinner();
void updateWinner();
// void fillPlayersInArray(Player **arr) {
// *arr = (Player *) malloc(numOfPlayers * sizeof(Player *));
//// if(numOfPlayers==0)
//// arr[0]= nullptr;
// (*Players).transferPlayers(arr);
// }
//
//
// void updatePlayers(AVL<Player *> plr) {
// *(this->Players) = plr;
// }
Player& getPlayerByID(int ID) {
// if(!Players.isExist(ID))
// return nullptr;
return (*Players).getData(ID);
}
void decreaseNumPlayers();
// void getBestPlayer(int* PlayerID);
void destroyClan() {
(*Players).destroyAVLWithoutRoot();
}
void updateNumPlayers(int n) {
this->numOfPlayers = n;
}
// void updateBestPlayer(int n) {
// this->bestPlayer = n;
// }
void updateNumofChal(int n) {
this->challengesOfBestPlayer = n;
}
void printID()
{
std::cout << "clan ID is " << this->id << std::endl;
}
};
// bool operator<(int x, Clan clan)
// {
// if(x<clan.getID()) return true;
// }
//void operator=(Clan& clan1,Clan& clan2)
//{
// clan1.numOfPlayers=clan2.numOfPlayers;
// clan1.id=clan2.id;
// clan1.Players=clan2.Players;
//}
#endif //HW1_CLAN_H