-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMotorVehicle_main.cpp
More file actions
83 lines (67 loc) · 2.53 KB
/
MotorVehicle_main.cpp
File metadata and controls
83 lines (67 loc) · 2.53 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
// 12191706 ±èÁ¤Áø
// Chpater 10 - 10.8
// test program to demonstrate MotorVehicle's capabilities.
#include <string>
#include <iostream>
#include "MotorVehicle.h" // MotorVehicle class definition
using namespace std;
int main() {
string company, fuel_name, car_color;
int made_year, engine_dur;
// new car has been created and display it's information
MotorVehicle newmotor("HD", 2000, 50);
cout << "New MotorVehicle has been created.\n"
<< "Display information by displayCarDetails function.";
newmotor.displayCarDetails();
// input new car's information
cout << "Fill in newmotor's make : ";
cin >> company;
newmotor.setMake(company);
cout << "Fill in newmotor's fuelType : ";
cin >> fuel_name;
newmotor.setFuelType(fuel_name);
cout << "Fill in newmotor's yearOfManufacture : ";
cin >> made_year;
newmotor.setYearOfManufacture(made_year);
cout << "Fill in newmotor's color : ";
cin >> car_color;
newmotor.setColor(car_color);
cout << "Fill in newmotor's engineCapacity : ";
cin >> engine_dur;
newmotor.setEngineCapacity(engine_dur);
// display new car's information by output operator(<<)
cout << "\nDisplay information by output operator." << newmotor;
// another new car has been created.
MotorVehicle anothermotor("BMW", 2010, 1);
cout << "Another new MotorVehicle has been created.\n";
// input anothercar's information
cout << "Fill in anothermotor's make : ";
cin >> company;
anothermotor.setMake(company);
cout << "Fill in anothermotor's fuelType : ";
cin >> fuel_name;
anothermotor.setFuelType(fuel_name);
cout << "Fill in anothermotor's yearOfManufacture : ";
cin >> made_year;
anothermotor.setYearOfManufacture(made_year);
cout << "Fill in anothermotor's color : ";
cin >> car_color;
anothermotor.setColor(car_color);
cout << "Fill in anothermotor's engineCapacity : ";
cin >> engine_dur;
anothermotor.setEngineCapacity(engine_dur);
// display new car's information by output operator(<<)
cout << "\nDisplay information by output operator." << newmotor;
// compare new car and another car and display greater one. (which was manufactured before than other)
if (newmotor == anothermotor)
cout << "Both motors are same model.\n";
else if (newmotor != anothermotor) {
cout << "Both motors are not same model.\nDisplay greater motor's information.\n";
if (newmotor > anothermotor)
cout << "Greater motor is newmotor." << newmotor;
else if(anothermotor > newmotor)
cout << "Greater motor is anothermotor." << anothermotor;
else
cout << "Both motors are not same model, but they are both great."
}
}