-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVIOPEtask
More file actions
98 lines (89 loc) · 2.11 KB
/
VIOPEtask
File metadata and controls
98 lines (89 loc) · 2.11 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
#include <iostream>
#include <string>
using namespace std;
class Vehicle
{
public:
int weight;
int top_speed;
long driven_km;
Vehicle(int weight, int top_speed, long driven_km);
void Drive(int journey);
int InputWeight();
int InputTopSpeed();
long InputDrivenKM();
};
Vehicle::Vehicle(int Aw, int Ats, long Akm)
{
weight = Aw;
top_speed = Ats;
driven_km = Akm;
}
void Vehicle::Drive(int journey)
{
driven_km += journey;
}
int Vehicle::InputWeight()
{
return weight;
}
int Vehicle::InputTopSpeed()
{
return top_speed;
}
long Vehicle::InputDrivenKM()
{
return driven_km;
}
class Car: public Vehicle{
public:
string brand, model, register_no;
bool running;
Car(int weight, int top_speed, long driven_km, string brand, string model, string register_no, bool running);
void turn_on();
void turn_off();
void check_up();
};
Car::Car(int weight, int top_speed, long driven_km, string car_brand, string car_model, string car_register_no, bool car_running): Vehicle(weight, top_speed, driven_km){
brand=car_brand;
model=car_model;
register_no=car_register_no;
running=car_running;
}
void Car::turn_on(){
running=1;
}
void Car::turn_off(){
running=0;
}
void Car::check_up(){
cout<<"car info:\nbrand:"<<brand<<"\nmodel:"<<model<<"\nKilometres:"<<driven_km<<"\nweight:"<<weight<<"\nTop speed:"<<top_speed<<"\nLicense plate:"<<register_no<<endl;
if (running) cout<<"car is running."<<endl;
else cout<<"car is not running."<<endl;
}
int main()
{
int weight, speed;
long km;
string brand, model, license;
// ask information about car
cout << "Input car brand: ";
cin >> brand;
cout << "Input car model: ";
cin >> model;
cout << "Input car license plate number: ";
cin >> license;
cout << "Input car weight: ";
cin >> weight;
cout << "Input car top speed: ";
cin >> speed;
cout << "Input distance traveled by car: ";
cin >> km;
cout << endl;
Car carX(weight, speed, km, brand, model, license, 0);
carX.check_up();
carX.turn_on();
carX.Drive(95);
cout << endl;
carX.check_up();
}