-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTerm-inator5000
313 lines (257 loc) · 9.97 KB
/
Term-inator5000
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
UML Diagram
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Class = PlayerInfo
Variables = PlayerName = string
PlayerNameCheck = string
AgeName = double
StudentCheck = bool
StudentAnswer = string
StudentSee = string
Objects = askName()
askAge()
studentChecking()
displayPlayerInfo()
Class = CourseInfo
Variables = CourseName = string[]
OptionNumber = int
OptionBiology = string[]
StoreCourseName = string
Objects = askCourse()
askOption()
Class = GameInfo
Variables = StartGame
ResponseOfPlayer
CourseDone
ExitGame
Objects = None yet
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Program
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System;
namespace SecondAssignment
{
class Program
{
//main
static void Main()
{
Console.Title = "Term-inator5000 by Ishan Dutta";
PlayerInfo NewPlayerInfo = new PlayerInfo();
NewPlayerInfo.askName();
NewPlayerInfo.askAge();
NewPlayerInfo.studentChecking();
NewPlayerInfo.displayPlayerInfo();
CourseInfo NewCourseInfo = new CourseInfo();
NewCourseInfo.askCourse();
NewCourseInfo.askOption();
Console.ReadKey();
}
}
//1st class that stores player information
public class PlayerInfo
{
//declaring variables
public string PlayerName = "";
public string PlayerNameCheck = "";
public double AgeName = 0;
public bool StudentCheck = true;
public string StudentAnswer = "";
public string StudentSee = "";
//player name object
public void askName()
{
Console.WriteLine("Please type your name: ");
PlayerName = Console.ReadLine();
Console.Write("Your selected name is ");
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.Write(PlayerName);
Console.ResetColor();
Console.Write(" .Are you satisfied with that name?\nPlease say yes or no.\n");
PlayerNameCheck = Console.ReadLine();
if (PlayerNameCheck == "yes")
{
Console.WriteLine("Thank you!");
}
else if (PlayerNameCheck == "no")
{
Console.WriteLine("Please select your preferred name: ");
PlayerName = Console.ReadLine();
}
else
{
Console.WriteLine("You don't have any name selected. Please restart");
}
Console.WriteLine("Your name is: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(PlayerName + "\n");
Console.ResetColor();
}
//player age object
public void askAge()
{
Console.WriteLine("Please select your age: ");
AgeName = Convert.ToInt32(Console.ReadLine());
/* Credits:
* https://stackoverflow.com/questions/24443827/reading-an-integer-from-user-input
* by Prasanth Jaya, September 1st, 2015
*/
Console.WriteLine("Your age is: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(AgeName + "\n");
Console.ResetColor();
}
//player student bool object
public void studentChecking()
{
Console.WriteLine("Are you a student?");
StudentAnswer = Console.ReadLine();
if (StudentAnswer == "yes")
{
StudentCheck = true;
StudentSee = "student";
}
else
{
StudentCheck = false;
StudentSee = "not a student";
}
}
//Display's player input
public void displayPlayerInfo()
{
Console.Write("Your name is: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(PlayerName);
Console.ResetColor();
Console.Write("\nYour age is: ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(AgeName);
Console.ResetColor();
Console.Write("\nYou are a ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(StudentSee);
Console.ResetColor();
Console.Write( ".\n");
}
}
public class CourseInfo
{
public string[] CourseName = { "Biology" };
//For next time when we learn loops
/*
"Chemsitry", "Maths", "Physics",};
public string[] OptionPhysics = {"Classical mechanics",
"Thermodynamics and statistical mechanics",
"Electromagnetism and electronics",
"Relativity",
"Quantum mechanics",
"Optics",
"Atomic, molecular, and optical physics",
"Condensed matter physics",
"High energy/particle physics",
"Nuclear physics"};
public string[] OptionChemistry = { "Organic chemistry",
"Inorganic Chemistry",
"Analytical Chemistry",
"Physical Chemistry",
"Biochemistry" };
public string[] OptionMaths = { "Algebra",
"Calculus and analysis",
"Geometry and topology",
"Combinatorics",
"Logic",
"Number theory",
"Dynamical systems and differential equations",
"Mathematical physics" };
*/
public string[] OptionBiology = { "1) Ethology",
"2) Entomology",
"3) Herpetology",
"4) Ichthyology",
"5) Mammalogy" };
public int OptionNumber = 0;
public string StoreCourseName = "";
public void askCourse()
{
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.WriteLine("Please select a course from the following: ");
Console.WriteLine(String.Join("\n", CourseName));
/* Credits:
* https://stackoverflow.com/questions/42112051/c-sharp-print-list-of-string-array
* by PulkitG, Feburary 8th, 2017
*/
StoreCourseName = Console.ReadLine();
Console.ResetColor();
if (StoreCourseName == "Biology")
{
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine("\nYou have selected Biology");
Console.ResetColor();
} else
{
Console.BackgroundColor = ConsoleColor.White;
Console.WriteLine("\nInvalid Response");
Console.ResetColor();
}
}
public void askOption()
{
Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("\nPlease select the option number you want to select? \n");
Console.WriteLine(String.Join("\n", OptionBiology));
Console.ResetColor();
OptionNumber = Convert.ToInt32(Console.ReadLine());
switch (OptionNumber)
{
case 1:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Ethology is the study of animal behaviour.");
Console.ResetColor();
break;
case 2:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Entomology is the study of insects.");
Console.ResetColor();
break;
case 3:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Herpetology is the study of reptiles and amphibians.");
Console.ResetColor();
break;
case 4:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Ichthyology is the study of fish");
Console.ResetColor();
break;
case 5:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Mammalogy is the study of mammals");
Console.ResetColor();
break;
default:
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("Invalid Option");
Console.ResetColor();
break;
}
}
}
/*
public class GameInfo
{
public bool StartGame;
public string ResponseofPlayer;
public int CourseDone;
public bool ExitGame;
}
*/
}
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Edit Log
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//Edit log #1:
//Added Color to the code
//Edit log #2:
//Added UML Diagram for brief understanding
//Made the code a little bit more pretty