Inheritance and Cleaning Up Code

I CANNOT FIND THE "DELETE THREAD" OPTION. IDK WHY, BUT (AS YOU CAN SEE) I POSTED MY ENTIRE CODE. MUCH OF IT IS FINE AND HAS NOTHING TO DO WITH MY ACTUAL PROBLEM. COULD SOMEONE BRING THIS TO THE ATTENTION OF AN ADMIN SO THAT THEY CAN DELETE MY THREAD. THANK YOU

Dev C++ 5.11 (Windows 7) - Console Application
So, I'm trying to create a fun little quiz for my daughters. I'm done a lot for the opening and getting to the log-in screen but it's here I'm having a problem. I have two daughters and was wondering if it is possible to create some sort of Inheritance to cut down on coding. The questions are the same for each daughter and the answers are multiple-choice. I'm not sure how to continue.
Also, if anyone has any ideas/suggestions on how to clean up my code a bit, it would be greatly appreciated. I still need to adjust the timing a bit and add a few beeps here and there as well but those aren't much concern at the moment.
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
#include <iostream> // Standart IO Stream

#include <ctype.h> // Upper/Lower Case
#include <stdlib.h> // System
#include <string> // String to Character
#include <time.h> // Random Numbers/Intervals
#include <windows.h> // Windows Based Headers
#include <iomanip>

using namespace std;

char
//Run Program
runProgramBegin[] = "Run program ssep.exe? (Y/N)\n",
cPrompt[] = "C:\\>",
runProgramInput,
terminatingProgram[] = "Program Terminating...\n",
statusBar[] = "\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2 ",
invalidEntry[] = "\nInput Not Recognized.\n\n",
invalidID[] = "\nAccess Denied. Please input valid User ID.",
//MegaMan X Intro
mm01[] = "NOM ENGINEER WORK SYSTEM\n",
mm02[] = "Model CPS-9204\n\n",
mm03[] = "Copyright (c) 2105, 2109, 2114\n",
mm04[] = "NOM Corporation\n",
mm05[] = "All Rights Reserved\n\n",
mm06[] = "real  mem = ",
mmtb[] = " TB\n",
mm07[] = "avail mem = ",
mm08[] = "\nprimary data cache : ",
mmkb[] = "KB\n",
mm09[] = "primary inst.cache : ",
mm10[] = "secondary cache    : ",
mm11[] = "\nlogin: ",
mm12[] = "Dr.CAIN\n",
mm13[] = "code : ",
mmasterisk[] = "******",
mm14[] = "device -dvl -a\n\n",
mm15[] = "reading ",
mm16[] = "M.X.S.\n",
mm17[] = "BD-E\n",
mm18[] = "WARNING\n",
//Title Screen
banner01[] = " \xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\n",
userID[] = "USER ID: ";

string
username,
siblingname,
userid;
Last edited on
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
int main ()
{
	//Unique Value Upon Startup
	srand (time(NULL));
	
	//Text Color
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	int textColor = 15;
	
	//Start-Up Pause and Beeps
	Sleep (1000);
	Beep (723,150);
	Sleep (2500);
	Beep (723,150);
	Beep (723,150);
	Sleep (1000);
	
	
	//Run Program "SSEP.exe"? (Y/N)
	SetConsoleTextAttribute(hConsole, 7);
	for (int i=0; runProgramBegin[i] != '\0'; i++)
	{
		if (i>=12 && i<=19)
		{
			SetConsoleTextAttribute(hConsole, 15);
		}
		Sleep ((1 + rand() % 10) * 10);
		cout << runProgramBegin[i];
		SetConsoleTextAttribute(hConsole, 7);
	}
	//C Prompt
	while (true)
	{
		
		Sleep(1000);
		for (int i=0; cPrompt[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 10) * 10);
			cout << cPrompt[i];
		}
		
		//Run Program User Input
		cin >> runProgramInput;
		cin.sync();
		runProgramInput = toupper(runProgramInput);
		
			//Run Program User Input - YES
			if (runProgramInput == 'Y')
			{
				system("CLS");
				Sleep(1500);
				break;
			}
			//Run Program User Input - NO
			if (runProgramInput == 'N')
			{
				Sleep(2000);
				system("CLS");
				Beep (723,250);
				Sleep(1000);
				cout << setfill ('\n') << setw (23) << setfill ('\t') << setw (4);
				for (int i=0; terminatingProgram[i] != '\0'; i++)
				{
					Sleep ((1 + rand() % 10) * 10);
					cout << terminatingProgram[i];
				}
				Sleep(1000);
				for (int i=0; statusBar[i] != '\0'; i++)
				{
					Sleep ((1 + rand() % 100) * 10);
					cout << statusBar[i];
				}
				Sleep(3000);
				return 0;
			}
			//Run Program User Input - INVALID
			if (runProgramInput != 'Y' && runProgramInput != 'N')
			{
				SetConsoleTextAttribute(hConsole, 12);
				for (int i=0; invalidEntry[i] != '\0'; i++)
				{
					Sleep ((1 + rand() % 10) * 10);
					cout << invalidEntry[i];
				}
				SetConsoleTextAttribute(hConsole, 7);
				continue;
			}
	}
	
	//PROGRAM START
	Sleep (1500);
	Beep(723,150);
	Beep(723,150);
	Sleep(1000);
	Beep(723,300);
	Sleep(1500);
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
//NOM ENGINEER WORK	
		SetConsoleTextAttribute(hConsole, 15);
		for (int i=0; mm01[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 10) * 10);
			cout << mm01[i];
		}
		//Model CPS-9204
		Sleep (1500);
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; mm02[i] != '\0'; i++)
		{
			if (i>=6 && i<=13)
			{
				SetConsoleTextAttribute(hConsole, 11);
			}
			Sleep ((1 + rand() % 10) * 10);
			cout << mm02[i];
			SetConsoleTextAttribute(hConsole, 7);
		}
		//Copyright (c) 2105, 2109, 2114
		Sleep (1000);
		for (int i=0; mm03[i] != '\0'; i++)
		{
			if(i>=14 && i<=17 || i>=20 && i<=23 || i>=26 && i<=29)
			{
				SetConsoleTextAttribute(hConsole, 11);
			}
			if(i==18 || i==24)
			{
				SetConsoleTextAttribute(hConsole, 8);
			}
			Sleep ((1 + rand() % 10) * 10);
			cout << mm03[i];
			SetConsoleTextAttribute(hConsole, 7);
		}
		//NOM Corporation
		Sleep (1500);
		SetConsoleTextAttribute(hConsole, 15);
		for (int i=0; mm04[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 5) * 10);
			cout << mm04[i];
		}
		//All Rights Reserved
		Sleep (1500);
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; mm05[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 5) * 10);
			cout << mm05[i];
		}
		//real mem = 8192 TB
		Sleep (1500);
		for (int i=0; mm06[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 5) * 10);
			cout << mm06[i];
		}
		Sleep (1500);
			cout << "\r";
			for (int realmem = 1; realmem != 2730; ++realmem)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "real  mem = ";
				SetConsoleTextAttribute(hConsole, 4);
				cout << realmem;
				cout << "\r";
			}
			for (int realmem = 2731; realmem != 5461; ++realmem)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "real  mem = ";
				SetConsoleTextAttribute(hConsole, 6);
				cout << realmem;
				cout << "\r";
			}
			for (int realmem = 5462; realmem != 8191; ++realmem)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "real  mem = ";
				SetConsoleTextAttribute(hConsole, 2);
				cout << realmem;
				cout << "\r";
			}
			SetConsoleTextAttribute(hConsole, 7);
			cout << "\r" << "real  mem = ";
			SetConsoleTextAttribute(hConsole, 11);
			cout << "8192";
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; mmtb[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 5) * 10);
			cout << mmtb[i];
		}
		//avail mem = 32768 TB
		Sleep (1500);
		for (int i=0; mm07[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm07[i];
		}
		Sleep (1500);
			cout << "\r";
			for (int availmem = 1; availmem != 10922; ++availmem)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "avail mem = ";
				SetConsoleTextAttribute(hConsole, 4);
				cout << availmem;
				cout << "\r";
			}
			for (int availmem = 10923; availmem != 21845; ++availmem)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "avail mem = ";
				SetConsoleTextAttribute(hConsole, 6);
				cout << availmem;
				cout << "\r";
			}
			for (int availmem = 21846; availmem != 32767; ++availmem)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "avail mem = ";
				SetConsoleTextAttribute(hConsole, 2);
				cout << availmem;
				cout << "\r";
			}
			SetConsoleTextAttribute(hConsole, 7);
			cout << "\r" << "avail mem = ";
			SetConsoleTextAttribute(hConsole, 11);
			cout << "32768";
		SetConsoleTextAttribute(hConsole, 7);	
		for (int i=0; mmtb[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mmtb[i];
		}
		//primary data cache : 512KB
		Sleep (1500);
		for (int i=0; mm08[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm08[i];
		}	
		Sleep (1500);
			cout << "\r";
			for (int cache01 = 1; cache01 != 170; ++cache01)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "primary data cache : ";
				Sleep (1 +rand() % 3);
				SetConsoleTextAttribute(hConsole, 4);
				cout << cache01;
				cout << "\r";
			}
			for (int cache01 = 171; cache01 != 341; ++cache01)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "primary data cache : ";
				Sleep (1 +rand() % 3);
				SetConsoleTextAttribute(hConsole, 6);
				cout << cache01;
				cout << "\r";
			}
			for (int cache01 = 342; cache01 != 511; ++cache01)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "primary data cache : ";
				Sleep (1 +rand() % 3);
				SetConsoleTextAttribute(hConsole, 2);
				cout << cache01;
				cout << "\r";
			}
			SetConsoleTextAttribute(hConsole, 7);
			cout << "\r" << "primary data cache : ";
			SetConsoleTextAttribute(hConsole, 11);
			cout << "512";
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; mmkb[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mmkb[i];
		}
		//primary inst. cache : 768KB
		Sleep (1500);
		for (int i=0; mm09[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm09[i];
		}
		Sleep (1500);
			cout << "\r";
			for (int cache02 = 1; cache02 != 256; ++cache02)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "primary inst.cache : ";
				Sleep (1 +rand() % 3);
				SetConsoleTextAttribute(hConsole, 4);
				cout << cache02;
				cout << "\r";
			}
			for (int cache02 = 257; cache02 != 512; ++cache02)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "primary inst.cache : ";
				Sleep (1 +rand() % 3);
				SetConsoleTextAttribute(hConsole, 6);
				cout << cache02;
				cout << "\r";
			}
			for (int cache02 = 513; cache02 != 767; ++cache02)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "primary inst.cache : ";
				Sleep (1 +rand() % 3);
				SetConsoleTextAttribute(hConsole, 2);
				cout << cache02;
				cout << "\r";
			}
			SetConsoleTextAttribute(hConsole, 7);
			cout << "\r" << "primary inst.cache : ";
			SetConsoleTextAttribute(hConsole, 11);
			cout << "768";
		SetConsoleTextAttribute(hConsole, 7);	
		for (int i=0; mmkb[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mmkb[i];
		}	
		//secondary cache : 32768KB
		Sleep (1500);
		for (int i=0; mm10[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm10[i];
		}
			Sleep (1500);
			cout << "\r";
			for (int cache03 = 1; cache03 != 10923; ++cache03)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "secondary cache    : ";
				SetConsoleTextAttribute(hConsole, 4);
				cout << cache03;
				cout << "\r";
			}
			for (int cache03 = 10924; cache03 != 21846; ++cache03)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "secondary cache    : ";
				SetConsoleTextAttribute(hConsole, 6);
				cout << cache03;
				cout << "\r";
			}
			for (int cache03 = 21847; cache03 != 32767; ++cache03)
			{
				SetConsoleTextAttribute(hConsole, 7);
				cout << "secondary cache    : ";
				SetConsoleTextAttribute(hConsole, 2);
				cout << cache03;
				cout << "\r";
			}
			SetConsoleTextAttribute(hConsole, 7);
			cout << "\r" << "secondary cache    : ";
			SetConsoleTextAttribute(hConsole, 11);
			cout << "32768";
		SetConsoleTextAttribute(hConsole, 7);
			for (int i=0; mmkb[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mmkb[i];
		}
		//login: Dr.CAIN
		Sleep (1500);
		for (int i=0; mm11[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm11[i];
		}
		SetConsoleTextAttribute(hConsole, 15);
		Sleep (1500);
		for (int i=0; mm12[i] != '\0'; i++)
		{
			Sleep ((5 + rand() % 10) * 10);
			cout << mm12[i];
		}
		//code : ******
		Sleep (1500);
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; mm13[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm13[i];
		}
		SetConsoleTextAttribute(hConsole, 15);
		Sleep (1500);
		for (int i=0; mmasterisk[i] != '\0'; i++)
		{
			Sleep ((5 + rand() % 10) * 10);
			cout << mmasterisk[i];
		}
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
//>device -dvl -a
		SetConsoleTextAttribute(hConsole, 12);	
		Sleep (1500);
		cout << "\n\n>";
		for (int i=0; mm14[i] != '\0'; i++)
		{
			Sleep ((5 + rand() % 10) * 10);
			cout << mm14[i];
		}
		//reading "M.X.S."
		Sleep (1500);
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; mm15[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm15[i];
		}
		Sleep (2000);
		SetConsoleTextAttribute(hConsole, 6);
		for (int i=0; mm16[i] != '\0'; i++)
		{
			Sleep ((5 + rand() % 10) * 10);
			cout << mm16[i];
		}
		SetConsoleTextAttribute(hConsole, 7);
		//reading "BD-E"
		Sleep (1500);
		for (int i=0; mm15[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm15[i];
		}
		Sleep (2000);
		SetConsoleTextAttribute(hConsole, 6);
		for (int i=0; mm17[i] != '\0'; i++)
		{
			Sleep ((5 + rand() % 10) * 10);
			cout << mm17[i];
		}
		SetConsoleTextAttribute(hConsole, 7);
		//reading "WARNING"
		Sleep (1500);
		for (int i=0; mm15[i] != '\0'; i++)
		{
			Sleep ((1 + rand() % 3) * 10);
			cout << mm15[i];
		}
		Sleep (2000);
		SetConsoleTextAttribute(hConsole, 6);
		for (int i=0; mm18[i] != '\0'; i++)
		{
			Sleep ((5 + rand() % 10) * 10);
			cout << mm18[i];
		}
		SetConsoleTextAttribute(hConsole, 7);
		Sleep(5000);
		system("CLS");
	//TITLE SCREEN
	cout << "\n";
	for (int i=0; banner01[i] != '\0'; i++)
	{
		SetConsoleTextAttribute(hConsole, 13);
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i>=3 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i>=6 && i<=73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i>=7 && i<=72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i >=23 && i <=26 || i >=38 && i <=41 || i >=53 && i <=56 || i >=67 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=12 && i<=22 || i>=27 && i<=37 || i>=42 && i<=52 || i>=57 && i<=66)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i>=15 && i<=20 || i >=23 && i <=26 || i>=30 && i<=35 || i >=38 && i <=41 || i>=45 && i<=50 || i >=53 && i <=56 || i>=60 && i<=64 || i >=68 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=12 && i<=14 || i>=21 && i<=22 || i>=27 && i<=29 || i>=36 && i<=37 || i>=42 && i<=44 || i>=51 && i<=52 || i>=57 && i<=59 || i>=65 && i<=67)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i >=15 && i <=26 || i >=30 && i <=41 || i >=45 && i <=56 || i>=60 && i<=65 || i >=68 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=12 && i<=14 || i>=27 && i<=29 || i>=42 && i<=44 || i>=57 && i<=59 || i>=66 && i<=67)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i >=15 && i <=26 || i >=30 && i <=41 || i >=45 && i <=47 || i>=49 && i<=56 || i>=60 && i<=64 || i >=68 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=12 && i<=14 || i>=27 && i<=29 || i>=42 && i<=44 || i==48 || i>=57 && i<=59 || i>=65 && i<=67)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i >=23 && i <=26 || i >=38 && i <=41 || i >=49 && i <=56 || i >=67 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=12 && i<=22 || i>=27 && i<=37 || i>=42 && i<=48 || i>=57 && i<=66)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=19 || i >=23 && i <=364 || i >=38 && i <=41 || i>=45 && i<=47 || i >=49 && i <=56 || i >=60 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=20 && i<=22 || i>=35 && i<=37 || i>=42 && i<=44 || i==48 || i>=57 && i<=59)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=19 || i >=23 && i <=364 || i >=38 && i <=41 || i>=45 && i <=56 || i >=60 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=20 && i<=22 || i>=35 && i<=37 || i>=42 && i<=44 || i>=57 && i<=59)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i>=14 && i<=19 || i >=23 && i <=26 || i>=29 && i<=34 || i >=38 && i <=41 || i>=45 && i<=50 || i >=53 && i <=56 || i >=60 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
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
if (i>=12 && i<=13 || i>=20 && i<=22 || i>=27 && i<=28 || i>=35 && i<=37 || i>=42 && i<=44 || i>=51 && i<=52 || i>=57 && i<=59)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=11 || i >=23 && i <=26 || i >=38 && i <=41 || i >=53 && i <=56 || i >=60 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		if (i>=12 && i<=22 || i>=24 && i<=25 || i>=27 && i<=37 || i>=39 && i<=40 || i>=42 && i<=52 || i>=54 && i<=55 || i>=57 && i<=59 || i>=61 && i<=62)
		{
			SetConsoleTextAttribute(hConsole, 11);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i >=8 && i <=71 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i==7 || i==72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 10);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i==6 || i==73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i>=7 && i<=72)
		{
			SetConsoleTextAttribute(hConsole, 7);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i>=6 && i<=73 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i>=3 && i<=5 || i>=74 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		if (i<=2 || i>=77)
		{
			SetConsoleTextAttribute(hConsole, 13);
		}
		if (i>=3 && i<=76)
		{
			SetConsoleTextAttribute(hConsole, 8);
		}
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	for (int i=0; banner01[i] != '\0'; i++)
	{
		SetConsoleTextAttribute(hConsole, 13);
		Sleep (1 + rand() % 50);
		cout << banner01[i];
	}
	Sleep(1500);
		cout << "\n\n";
		cout << setfill ('\t') << setw (5);
	
	while (true)
	{
		SetConsoleTextAttribute(hConsole, 7);
		for (int i=0; userID[i] != '\0'; i++)
		{
		Sleep ((1 + rand() % 10) * 10);
		cout << userID[i];
		}
		SetConsoleTextAttribute(hConsole, 15);
		cin >> userid;
			//User ID - KaeLynn
			if (userid == "kaEKAe80022221")
			{
				username = "KAELYNN";
				siblingname = "GABRIELLA";
				system("CLS");
				Sleep(1500);
				break;
			}
			//User ID - Gabriella
			if (userid == "goOBs11020270")
			{
				username = "GABRIELLA";
				siblingname = "KAELYNN";
				system("CLS");
				Sleep(1500);
				break;
			}
			//User ID - INVALID
			if (userid != "kaEKAe80022221" && userid != "goOBs11020270")
			{
				Sleep(1500);
				SetConsoleTextAttribute(hConsole, 12);
				for (int i=0; invalidID[i] != '\0'; i++)
				{
					Sleep ((1 + rand() % 10) * 10);
					cout << invalidID[i];
				}
				Sleep(1000);
				system("CLS");
				continue;
			}
	}
	/*SetConsoleTextAttribute(hConsole, 7);	
	cout << "User ID: ";
	SetConsoleTextAttribute(hConsole, 13);
	cout << username << setfill(' ') << setw(54);
	SetConsoleTextAttribute(hConsole, 7);
	cout << "Sibling: ";
	SetConsoleTextAttribute(hConsole, 13);
	cout << siblingname << "\n\n";*/
	
	
	
	//End
	SetConsoleTextAttribute(hConsole, 7);
	cin.get();
	Sleep(3000);
	system("CLS");
	cout << "WORKING!!!" << endl;
	cin.get();
	return 0;
}
Yikes, man. I don't think anybody is going to be able to read that cruft. In any case, inheritance is only used when you have classes. Since you don't have any classes, you aren't going to be able to inherit from anything.
Two things to consider when making variables (especially global ones)

1. Is this used once? If so, is it changed? If not, use a literal instead
2. Is this variable used in more than one function scope? If not, then you don’t need it to be global. Also consider: What is the smallest possible scope in which this variable needed?


Now let’s apply this to the massive amount of variables you declared.

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
 char
//Run Program
runProgramBegin[] = "Run program ssep.exe? (Y/N)\n", // this looks like it’s only used once, and never changed. Use a literal instead.
cPrompt[] = "C:\\>", // hm. Yeah looks like it could just be a literal too.
runProgramInput, // seems like it could be in a much smaller scope. Where is the place where you set it to the input? put it in that scope.
terminatingProgram[] = "Program Terminating...\n", // this looks like a one time thing. Use a literal
statusBar[] = "\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2
\xB2\xB2 ", // seems like it could be a literal. Also a better way to define this would be (string('\xB2',78))
invalidEntry[] = "\nInput Not Recognized.\n\n", // this seems like a literal.
invalidID[] = "\nAccess Denied. Please input valid User ID.", // this also seems like a literal
//MegaMan X Intro
mm01[] = "NOM ENGINEER WORK SYSTEM\n", // mm01 to mm18 could be made into a multidimensional array, or even just one string it looks like. actually it looks like they all could be literals (some of them possibly combined)
mm02[] = "Model CPS-9204\n\n",
mm03[] = "Copyright (c) 2105, 2109, 2114\n",
mm04[] = "NOM Corporation\n",
mm05[] = "All Rights Reserved\n\n",
mm06[] = "real  mem = ",
mmtb[] = " TB\n",
mm07[] = "avail mem = ",
mm08[] = "\nprimary data cache : ",
mmkb[] = "KB\n",
mm09[] = "primary inst.cache : ",
mm10[] = "secondary cache    : ",
mm11[] = "\nlogin: ",
mm12[] = "Dr.CAIN\n",
mm13[] = "code : ",
mmasterisk[] = "******",
mm14[] = "device -dvl -a\n\n",
mm15[] = "reading ",
mm16[] = "M.X.S.\n",
mm17[] = "BD-E\n",
mm18[] = "WARNING\n",
//Title Screen
banner01[] = " \xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1\xB1
\xB1\xB1\n", // this looks like a literal. Also you could do the same thing I suggested with statusBar[] with this too.
userID[] = "USER ID: "; // looks like a literal.

// probably could put all of these in a smaller scope.
string
username,
siblingname, 
userid;



Edit: *Much later after thread already basically closed* let’s just see how that would have reduced things..

1
2
3
4
5
6
7
char 
// 2 moved to literals
// 1 moved to smaller scope
// 2 moved to literals ("blah...", and std::string('\xB1',78); )
// 2 moved to literals
// 20 moved to literals
Last edited on
Looking at it a second time and at the main code... I’d say make some functions actually.

Edit: yeah, like a slow_print function...
Last edited on
Ok so I’m seeing a lot of

1
2
3
4
5
	for (int i=0; XXX[i] != '\0'; i++)
	{
		Sleep ((1 + rand() % 10) * 10);
		cout << XXX[i];
	}


This could easily be changed to

1
2
3
4
5
6
7
8
9
10
11
12
void slow_print(std::string str){
  for(int i = 0; i < str.length(); i++) {
    Sleep ((1 + rand() % 10) * 10);
    cout << str[i];
  }
}

// blah blah blah code code....

slow_print("some literal");
// or
slow_print(some_string);


Edit: hm... I’m seeing some variety in the randomness of the wait span too though, so maybe something more like

1
2
3
4
5
6
7
8
9
10
11
12
void slow_print(std::string str, int vary){
  for(int i = 0; i < str.length(); i++) {
    Sleep ((1 + rand() % vary) * 10);
    cout << str[i];
  }
}

// blah blah blah code code....

slow_print("some literal",10);
// or
slow_print(some_string,10);



Edit2: actually... I’m seeing a lot of color changes too, so maybe instead you could do one that also provides a comp func and a selection of default an change colors or maybe... this:

1
2
3
4
5
6
7
8
9
10
11
void slow_cprint(std::string str,int wait_margin, function<int(char)> whatColor) {
  HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  for(char c : str) {
    Sleep((1 + rand() % wait_margin) * 10);
    SetConsoleTextAttribute(hConsole, whatColor(c));
    cout << c;
  }
}

// blah blah code code....
slow_cprint("some literal", 10, [](char c) ->int { return (c >=12 && c <=19 ? 15 : 7); });


Edit3: oops seems like I got wrong which var mattered. Hm. Actually... are you just trying to make it half one color and half another? That’d be easy enough to code...
Last edited on
Aw I was having so much fun :(

...


Imma do it anyways I’m too bored rn lol. Not gonna be as good as that guy’s, but still it’ll be fun.
Or actually nah I’m just fucking around so I shouldn’t,
I now see why you posted a second time: you had no color before and now you want to integrate it. Well that should be easy. Just add another class for the colored strings.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <functional> // function<>

// ...

class TypeColoredString : public TypeString {
  function<int(int)> whatColor_;
  public:
  TypeColoredString(std::string str, function<int(int)> whatColor, int delay = 25) : str_(str), delay_(delay) {}

  void execute() override {
    HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
    for(int i = 0;i < str_.length(); i++) {
      SetConsoleTextAttribute(hConsole, whatColor_(i));
      std::cout << str_[i] << flush;
      usleep(delay_ * 1000);
    }
  }
};
Last edited on
Topic archived. No new replies allowed.