-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerAdult.h
93 lines (69 loc) · 1.69 KB
/
PlayerAdult.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
#ifndef _PLAYER_ADULT_
#define _PLAYER_ADULT_
#include "PlayerBase.h"
template <typename T>
class PlayerAdult : public PlayerBase<T>
{
public:
PlayerAdult();
PlayerAdult(string _name);
PlayerAdult(const PlayerAdult &p);
PlayerAdult operator=(PlayerAdult &p);
void AddOneCard();
void AddAttackCards(int cards);
~PlayerAdult();
};
// template<typename T>
// void PlayerAdult<T>::SetName(string _name){
// name = _name;
// }
// template<typename T>
// string PlayerAdult<T>::GetName(){
// return name;
// }
template <typename T>
PlayerAdult<T>::PlayerAdult()
{
PlayerBase<T>::name = "";
PlayerBase<T>::attackCards.clear();
}
template <typename T>
PlayerAdult<T>::PlayerAdult(string _name)
{
PlayerBase<T>::name = _name;
PlayerBase<T>::attackCards.clear();
}
template <typename T>
PlayerAdult<T>::PlayerAdult(const PlayerAdult &p)
{
PlayerBase<T>::name = p.name;
copy(p.attackCards.begin(), p.attackCards.end(), this->attackCards.begin());
}
template <typename T>
PlayerAdult<T> PlayerAdult<T>::operator=(PlayerAdult &p)
{
PlayerBase<T>::name = p.name;
copy(p.attackCards.begin(), p.attackCards.end(), this->attackCards.begin());
return p;
}
template <typename T>
void PlayerAdult<T>::AddAttackCards(int cards)
{
PlayerBase<T>:: attackCards.clear();
for (int i = 0; i < cards; i++)
{
T x = static_cast<T>(rand() % (15) + 1);
PlayerBase<T>:: attackCards.push_back(x);
}
}
template <typename T>
void PlayerAdult<T>::AddOneCard()
{
T x = static_cast<T>(rand() % (15) + 1);
PlayerBase<T>:: attackCards.push_back(x);
}
template <typename T>
PlayerAdult<T>::~PlayerAdult()
{
}
#endif