forked from matkatmusic/PFMCPP_Project3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
496 lines (421 loc) · 11.1 KB
/
main.cpp
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
/*
Project 3 - Part 1a-d / 5
Video: Chapter 2 Part 5
User-Defined Types
Create a branch named Part1
Purpose: The entire purpose of this 5-part project is to get you
writing C++ code that compiles and to reinforce the syntax habits
that C++ requires.
What you create in this project will be used as the basis of
Project 5 in C++ Language Fundamentals.
************************
Part1 purpose: Learn to write User-Defined Types (UDTs)
You are going to write 10 UDTs in project3.
Part1 will be broken up into 5 separate steps, all on the same branch.
Part 1a: you will learn to think about an object in terms of
its sub-objects.
Part 1b: you will write 4 un-related UDTs in plain english.
Part 1c: you will write 1 UDT in plain english that will be
made of 5 related sub-objects.
Part 1d: you will write plain-english UDTs for the 5
sub-objects that form the UDT defined in Part 1c.
Part 1e: you will convert those 10 plain-english UDTs into code
that runs.
************************
*/
/*
Part 1a - Lesson
1) Look at the picture of the car interior (Part1a pic.jpg).
It's in the list of files on the left in Replit.
Fill in the blanks below which break this car interior down
into sub-objects.
Several sub-objects are listed below that make up this car's interior.
you're going to name several things that you'll find on each
subobject.
you're going to name several things that each subobject can do.
If you've seen "Family Feud", we are going to do what they do
in that show.
A few blanks are filled in for you already.
Main Object: Car Interior
Sub Object 1: Steering Wheel
Name 4 things you'll find on the: Steering Wheel
1) paddle shifters
2) 'cruise control' controls
3)
4)
Name 2 things you can do with the: Steering Wheel
1) adjust cruise control settings.
2)
Sub Object 2: Instrument Cluster
Name 4 things you'll find on the: Instrument Cluster
1)
2)
3)
4)
Name 3 things you can do with the: Instrument Cluster
1)
2)
3)
Sub Object 3: Environment Controls
Name 3 things you'll find on the: Environment Controls
1)
2)
3)
Name 3 things you can do with the: Environment Controls
1)
2)
3)
Sub Object 4: Infotainment System
Name 3 things you'll find on the: Infotainment System
1)
2)
3)
Name 3 things you can do with the: Infotainment System
1)
2)
3)
Sub Object 5: Seat
Name 3 things you'll find on the: Seat
1)
2)
3)
Name 2 things you can do with the: Seat
1)
2)
*/
/*
Part 1b - Lesson
Now you have some basic understanding of how to think of an object
in terms of its sub-objects.
Next, write 4 un-related UDTs in plain english:
*/
/*
example:
Thing: Car Wash
5 properties:
- number of vacuum cleaners
- number of eco-friendly cleaning supplies
- the amount of water used per week.
- amount of profit made per week
- number of cars serviced per day
3 things it can do:
- wash and wax car
- charge customer
- detail the car interior
Notice that I did not use "has a vacuum cleaner" or "Has
eco-friendly cleaning supplies" as one of the properties.
Writing 'has a ___" checks whether or not your object **has the
ability to do something**.
Instead, I wrote "number of vacuum cleaners" and "number of
eco-friendly cleaning supplies".
These are specific objects or amounts.
In C++ terms, this means to I want you to avoid using 'bool'
(has a) as a member variable type.
Instead, prefer the other primitive types.
In addition to the usual primitives (covered in Project 2), you
can use 'std::string' to represent strings in this project.
*/
/*
===================
Part 1b Assignment: 1 Step
===================
1) Fill in the 4 UDTs below with a random UDT in plain english.
These 4 UDTs do not need to be related.
a) For each plain-english UDT, write out 5 traits or
properties and 3 things it can do.
b) remember: these properties will eventually become
primitives.
c) pick properties that can eventually be represented with
'int float double bool char std::string'.
*/
/*
Thing 1)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 2)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 3)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 4)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Part 1c - Lesson
You have just finished practicing writing out a UDT that is has
5 properties and can perform 3 actions.
Now you will write 1 UDT in plain english.
This UDT will be different than the previous 4 you wrote: It will
use UDTs to describe its 5 properties, as opposed to using C++
primitives to describe the 5 properties.
You will define these 5 'property' UDTs in Part 1d.
*/
/*
Part 1c example:
Cell Phone
A Cell Phone is built using the following 5 UDTs:
Display
Memory
CPU
Radio
Applications
A Cell Phone has 3 things it can do:
make a call
send a text
run an application.
Notice that I did not use "has a display" or "Has memory" or
"has a cpu" as one of the properties of the CellPhone.
Writing 'has a ___" checks whether or not your object **has
the ability to do something**.
Instead, I wrote "Display" or "CPU". These are specific
objects or amounts.
In C++ terms, this means to I want you to avoid using 'bool'
(has a) as a member variable type.
Instead, prefer the other primitive types.
When you choose your 5 smaller parts, remember that each of
these 5 Sub Objects will need to be defined with 5 primitive
properties and 3 actions EACH.
*/
/*
===================
Part 1c assignment: 2 steps
===================
1) write the name of the primitive type you'll be using after each
property in UDTs 1-4 from Part 1b:
pick properties that can be represented with
'int float double bool char std::string'.
example:
Display:
Number of Pixels (int)
Amount of Power consumed (milliwatt-hours) (float)
Brightness (double)
area in cm2 (int)
brand (std::string)
2) Fill in the 10th UDT below.
Define an object that is made of 5 sub-objects.
These 5 sub-objects will not be defined using Primitives, but instead will be their own UDTs
you'll define these 5 sub-objects in Part 1d.
*/
/*
Thing 10)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Part 1d - Lesson
You now know how to define a UDT that is composed of other UDT.
Now you will learn how to break down those sub-object UDTs into
their 5 properties and 3 actions.
The goal of Part 1d is to get you to think about breaking down an
object into smaller and smaller objects, until the smallest object
is made of up only C++ primitives and std::string.
Revisiting the previous example:
Cell Phone
A Cell Phone is made up of the following 5 properties/sub-objects
and 3 actions:
Display
Memory
CPU
Radio
Applications
3 actions:
make a call
send a text
run an application.
These 5 properties can be broken down into their own sub-objects
and properties.
If we break down the first property 'Display' into its 5 properties
we get:
brightness
amount of power consumed.
pixels
width in cm
height in cm
the Display's brightness can be represented with a Primitive,
such as a double.
The amount of power consumed can also be represented with a
Primitive, such as a float or integer (i.e. 250mWa)
The 'pixels' property must be represented with an array of Pixel
instances, as the screen has more than 1 row of pixels.
Arrays have not been discussed and can't be used in this
project.
Instead, we can use an Integer primitive to store the
Number of Pixels:
Display:
Number of Pixels
Amount of Power consumed (milliwatt-hours)
Brightness
width in cm
height in cm
As you can see, the 'Display' UDT has been broken down to the
point of being able to describe it with C++ primitives.
*/
/*
===================
Part 1d assignment: 3 Parts.
===================
1) Fill in #5 - #9 below with plain-english UDTs for the 5
properties you created for UDT #10.
example:
If #10's first property was 'Engine', then `Thing 5)`
will be `Engine`.
You will need to provide 5 properties and 3 member
functions of that Engine object in plain English.
Remember to pick properties that can be represented
with 'int float double bool char std::string'.
2) write the name of the primitive type you'll be using after
each property for UDTs 5 - 9.
You already did this for UDTs 1-4 in Part 1c.
Pick properties that can be represented with
'int float double bool char std::string'
example:
Display:
Number of Pixels (int)
Amount of Power consumed (milliwatt-hours) (float)
Brightness (double)
width in cm (int)
height in cm (int)
Step 3 is written below UDTs 5 - 9
*/
/*
Thing 5)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 6)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 7)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 8)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
Thing 9)
5 properties:
1)
2)
3)
4)
5)
3 things it can do:
1)
2)
3)
*/
/*
===================
Part 1d assignment: Step 3
===================
You've just defined 10 UDTs!
4 of them are unrelated (UDTs 1-4).
5 of them form the sub-objects that make up the 10th UDT.
MOVE THEM BELOW this block comment and put them in numerical order
(1 - 10) starting on line 473
DO NOT COPY.
I do not want to see 2 copies of your Plain-English UDTs.
I only want to see the 10 UDTs written BELOW this block comment, in numerical order (1 - 10).
After you have MOVED your 10 UDTs, send me a DM with your pull request link.
I will review the pseudo-code that you have written.
*/
/*
MAKE SURE YOU ARE NOT ON THE MASTER BRANCH
Commit your changes by clicking on the Source Control panel on the left, entering a message, and click [Commit and push].
If you didn't already:
Make a pull request after you make your first commit
pin the pull request link and this repl.it link to our DM thread in a single message.
send me a DM to review your pull request when the project is ready for review.
Wait for my code review.
*/
#include <iostream>
int main()
{
std::cout << "good to go!" << std::endl;
}