-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfundamentals
More file actions
127 lines (105 loc) · 3.76 KB
/
Copy pathfundamentals
File metadata and controls
127 lines (105 loc) · 3.76 KB
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
// I use a tailored version of Hungarian Notation to name my variables where I put a little hint of what type it is at the beginning, then I add an underscore, and after that, I write what the variable is for. The Camelcase notation is used to delimit words.
// Note: Please read the relevant commit description for a headsup.
#include <iostream>
using namespace std;
int main()
{
// Input Variables
char c_menuChoice;
char c_gameChoice;
// State Variables
bool b_validMenuChoice = false;
bool b_validGameChoice = false;
bool b_playGame = false;
// Display Menu and Instructions.
cout << "Instructions: Enter the option number to navigate through the game. Enjoy!" << endl;
cout << "1. Play Game" << endl << "2. Exit Game" << endl;
// Menu Handling
do
{
cout << "> ";
cin >> c_menuChoice;
switch (c_menuChoice)
{
case '1':
b_validMenuChoice = true;
b_playGame = true;
break;
case '2':
b_validMenuChoice = true;
break;
default:
b_validMenuChoice = false;
cout << "Please enter a valid choice" << endl;
break;
}
} while (!b_validMenuChoice);
// Game Loop
if (b_playGame)
{
cout << "You wake up in a room and a weapon is infront of you."
<< "\n1. Pick it up."
<< "\n2. Go out" << endl;
do
{
cout << "> ";
cin >> c_gameChoice;
switch (c_gameChoice)
{
case '1':
b_validGameChoice = true;
cout << "You have the gun." << "\n1. Kill the Zombies." << "\n2. Suicide." << endl;
do
{
cout << "> ";
cin >> c_gameChoice;
switch (c_gameChoice)
{
case '1':
b_validGameChoice = true;
cout << "You Win!" << endl;
break;
case '2':
b_validGameChoice = true;
cout << "You Lose! Game Over!" << endl;
break;
default:
b_validGameChoice = false;
cout << "Please enter a valid option." << endl;
break;
}
} while (!b_validGameChoice);
break;
case '2':
b_validGameChoice = true;
cout << "There are zombies." << "\n1. Run." << "\n2. Fight them." << endl;
do
{
cout << "> ";
cin >> c_gameChoice;
switch (c_gameChoice)
{
case '1':
b_validGameChoice = true;
cout << "You Lose! Game Over!" << endl;
break;
case '2':
b_validGameChoice = true;
cout << "You Lose! Game Over!" << endl;
break;
default:
b_validGameChoice = false;
cout << "Please enter a valid option." << endl;
break;
}
} while (!b_validGameChoice);
break;
default:
b_validGameChoice = false;
cout << "Please enter a valid option." << endl;
break;
}
} while (!b_validGameChoice);
}
return 0;
}