-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.h
executable file
·240 lines (178 loc) · 7.28 KB
/
Player.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
//
// Player.h
// The Q Factor
//
// Created by Leo N. on 11/21/16.
// Copyright © 2016 Leo Neto. All rights reserved.
//
#ifndef Player_h
#define Player_h
#include "Libraries.h"
class Player{
private:
// Integers and Booleans
int playerage;
int playerscore;
//int srand(time(NULL));
bool correctAnswer;
// Strings
std::string playername;
std::string playerlanguage;
std::string playeranswer;
std::string feedback;
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
public:
// Contructors
Player(){
playerscore = 0;
}//NULL constructor
Player(std::string username, int age){
Player::playername = username;
Player::playerage = age;
}//end User constructor
// *** end Contructors
~Player(){
}//destructor
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
void SetPlayer(){
std::cout << "What is your name: ";
getline(std::cin, playername);
std::cout <<""<< std::endl;
std::cout << "Alright, "<<getPlayerName()<<". You're all set to take the quiz."<<std::endl;
}//end SetPlayer()
// *** Name Methods
void setPlayerName(std::string username){
Player::playername = username;
}//end setName(); no return
std::string getPlayerName(){
return playername;
}//end getUserName(); returns name
// *** end Name Methods
// *** Language Methods
void setPlayerLanguage(std::string userlanguage){
Player::playerlanguage = userlanguage;
}//end setUserLanguage();
std::string getPlayerLanguage(){
return playerlanguage;
}//end getUserLanguage();
// **** end Langauge Methods
// *** Age Methods
void setPlayerAge(int userage){
Player::playerage = userage;
}//end setUserAge();
int getPlayerAge(){
return playerage;
}//end getUserAge();
// *** end Age Methods
// *** Answer Methods
void setPlayerAnswer(std::string answer){
Player::playeranswer = answer;
}//end setUserAnswer
std::string getPlayerAnswer(){
return playeranswer;
}//end get UserAnswer();
//*** end Answer Methods
// *** Feedback Methods
void setPlayerFeedback(std::string feedback){
Player::feedback = feedback;
}//end setUserAnswer
std::string getPlayerFeedback(){
return feedback;
}//end get UserAnswer();
//*** end Feedback Methods
// *** Score Methods
void IncreaseScore(){
Player::playerscore++;
}//end setUserScore()
int getPlayerScore(){
return playerscore;
}//end setUserScore()
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
void Greet(){
if(getPlayerAge()>9 & getPlayerAge()<39){
std::cout <<"Hope you're ready for some prime time!"<<std::endl;
std::cout <<"You can expect me to ask you questions from the past ";
std::cout <<getPlayerAge()-2*2<<" years or so..."<<std::endl;
} // Older than 9, younger than 39
else if(getPlayerAge()>=39){
std::cout <<getPlayerAge()<<" uh...? ";
std::cout <<"Quite a journey on your shoes!"<<std::endl;
std::cout <<"Don't worry, you've lived long enough to know the answers to these questions."<<std::endl;
}// Older than 39
else if(getPlayerAge()<=9){
std::cout <<"You are quite a young fellow to play this game."<<std::endl;
std::cout <<"Alright, I'll have to only ask you questions from the past ";
std::cout <<getPlayerAge()<<" years." <<std::endl;
} // Younger and equal to 9 years of age.
}//end Greet()
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
//*************************************************
void isCorrect(){
long long randomized = rand()%700;
if((randomized)%2 == 0){
std::cout <<"Well done!"<<std::endl;
}else if(randomized%3 == 0){
std::cout <<"Young and bright!"<<std::endl;
}else if(randomized%5 == 0){
std::cout<<"Correct is an understatement. Well done!"<<std::endl;
}else if((randomized)%7 == 0){
std::cout <<"Yeah, make me proud...!"<<std::endl;
}else if(randomized%2 == 1){
std::cout <<"I'm sure you've been reading a lot!"<<std::endl;
}else if((randomized)%3 == 1){
std::cout <<"Experience has it all!"<<std::endl;
}else if(randomized%5 == 1){
std::cout <<"Exactly what I expected!"<<std::endl;
}else if(randomized%7 == 1){
std::cout <<"Overflowing knowledge..."<<std::endl;
}else{
std::cout <<"That is absolutely correct!"<<std::endl;
}
}//end isCorrect()
void isWrong(){
long long randomized = rand()%700;
if((randomized)%2 == 0){
std::cout <<"Not, quite."<<std::endl;
}else if(randomized%3 == 0){
std::cout <<"Not exactly what either of us expected."<<std::endl;
}else if(randomized%5 ==0){
std::cout <<"Even I knew that..."<<std::endl;
}else if(randomized%7 == 0){
std::cout <<"No experience, uh!?"<<std::endl;
}else if(randomized%2 == 1){
std::cout <<"Well, you should have googled that..."<<std::endl;
}else if(randomized%3 == 1){
std::cout <<"Tricky, uh!?"<<std::endl;
}else if(randomized%5 == 1){
std::cout <<"Sorry you missed that."<<std::endl;
}else{
std::cout <<"Let's keep trying to get one right..."<<std::endl;
}
}//end isWrong()
};//endof Player
#endif /* Player_h */