-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_3.cpp
More file actions
66 lines (56 loc) · 1.37 KB
/
4_3.cpp
File metadata and controls
66 lines (56 loc) · 1.37 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
#include <iostream>
#include <vector>
using namespace std;
class FuelType {
protected:
string fuel;
public:
FuelType(string f) {
fuel = f;
}
void displayFuel() const {
cout << "Fuel Type: " << fuel << endl;
}
};
class Brand {
protected:
string brandName;
public:
Brand(string b) {
brandName = b;
}
void displayBrand() const {
cout << "Brand Name: " << brandName << endl;
}
};
class Car : public FuelType, public Brand {
public:
Car(string f, string b) : FuelType(f), Brand(b) { }
void showCarDetails() const {
displayBrand();
displayFuel();
}
};
int main() {
vector<Car> serviceQueue;
int n;
cout << "Enter number of cars: ";
cin >> n;
for (int i = 0; i < n; ++i) {
string fuel, brand;
cout << "\nEnter details for Car :\n";
cout << "Enter Brand Name: ";
cin >> brand;
cout << "Enter Fuel Type (Petrol/Diesel/Electric): ";
cin >> fuel;
Car c(fuel, brand);
serviceQueue.push_back(c);
}
cout << "\nCars in Service Queue:\n";
for (int i = 0; i < serviceQueue.size(); ++i) {
cout << "\nCar " << i + 1 << " Details:\n";
serviceQueue[i].showCarDetails();
}
cout<<"\n24CE052_Pushti kansara";
return 0;
}