-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (36 loc) · 1 KB
/
main.cpp
File metadata and controls
48 lines (36 loc) · 1 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
/**
* @author: walther
* @date: Sept 2018
*/
#include <string>
#include <iostream>
#include "Car.hpp"
#include "CarDealer.hpp"
#include "PrinterIterator.hpp"
// Define a specialized version of printJson for characters.
void printJson(char & charObj) {
// Check to ensure character is printable.
if ((static_cast<uint8_t>(charObj) >= 32) && (static_cast<uint8_t>(charObj) <= 126)) {
std::cout << charObj;
} else {
std::cout << " ";
}
}
// Main entry point to the program.
int main()
{
// Instantiate the classes.
Car car1 = {250, 3.5, "car1"};
Car car2 = {260, 3.6, "car1"};
Car car3 = {275, 3.75, "car1"};
Chevy chevy = { 315, 4.2, "Tahoe", 2005, Platform::CAR };
CarDealer dealer = { 3.3, {car1, car2, car3} };
// Print their fields.
printJson(car1);
std::cout << std::endl;
printJson(chevy);
std::cout << std::endl;
printJson(dealer);
std::cout << std::endl << "Successful completion!" << std::endl;
return EXIT_SUCCESS;
}