-
Notifications
You must be signed in to change notification settings - Fork 49
/
v.cpp
152 lines (116 loc) · 2.83 KB
/
v.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
#include <iostream>
using namespace std;
class vehicle{
public:
float mileage;
long price;
void a(){
cout<<" - Mileage: "<<mileage<<" kmpl"<<endl;
cout<<" - Price: "<<price<<" Rs"<<endl;
}
};
class car: public vehicle{
public:
long ownership_cost;
int warranty, seat_capacity;
string fuel_type;
void b(){
cout<<" - Ownership Cost: "<<ownership_cost<<" Rs"<<endl;
cout<<" - Warranty: "<<warranty<<" Years"<<endl;
cout<<" - Seating Capacity: "<<seat_capacity<<endl;
cout<<" - Fuel Type: "<<fuel_type<<" LItres"<<endl;
}
};
class bike: public vehicle{
public:
int num_of_cylinders, num_of_gears, fuel_tank_size;
string cooling_type, wheel_type;
void c(){
cout<<" - Number of Cylinders: "<<num_of_cylinders<<endl;
cout<<" - Number of Gears: "<<num_of_gears<<endl;
cout<<" - Cooling Type: "<<cooling_type<<endl;
cout<<" - Wheel Type: "<<wheel_type<<endl;
cout<<" - Fuel Tank Size: "<<fuel_tank_size<<" LItres"<<endl;
}
};
class audi: public car{
public:
string model_type;
void d(){
cout<<" - Model Type: "<<model_type<<endl;
}
};
class ford: public car{
public:
string model_type;
void e(){
cout<<" - Model Type: "<<model_type<<endl;
}
};
class bajaj: public bike{
public:
string make_type;
void f(){
cout<<" - Make Type: "<<make_type<<endl;
}
};
class tvs: public bike{
public:
string make_type;
void g(){
cout<<" - Make Type: "<<make_type<<endl;
}
};
int main() {
audi ai;
ai.mileage=65.45;
ai.price=650000;
ai.ownership_cost=350000;
ai.warranty=3;
ai.seat_capacity=4;
ai.fuel_type="Petrol";
ai.model_type="A56";
ford fd;
fd.mileage=78.45;
fd.price=950000;
fd.ownership_cost=550000;
fd.warranty=5;
fd.seat_capacity=4;
fd.fuel_type="Diesel";
fd.model_type="F22";
bajaj bj;
bj.mileage=95.26;
bj.price=250000;
bj.num_of_cylinders=3;
bj.num_of_gears=4;
bj.fuel_tank_size=45;
bj.cooling_type="Oil";
bj.wheel_type="Alloys";
bj.make_type="Road Bike";
tvs ts;
ts.mileage=101.45;
ts.price=350000;
ts.num_of_cylinders=4;
ts.num_of_gears=6;
ts.fuel_tank_size=65;
ts.cooling_type="Liquid";
ts.wheel_type="Spokes";
ts.make_type="Mountain Bike";
cout<<"\n\n------------- Audi -------------\n"<<endl;
ai.a();
ai.b();
ai.d();
cout<<"\n\n------------- Ford -------------\n"<<endl;
fd.a();
fd.b();
fd.e();
cout<<"\n\n------------- Bajaj -------------\n"<<endl;
bj.a();
bj.c();
bj.f();
cout<<"\n\n------------- TVS -------------\n"<<endl;
ts.a();
ts.c();
ts.g();
return 0;
}