Repository navigation
Expand file tree
/
Copy pathDmt.cpp
More file actions
92 lines (79 loc) · 2.23 KB
/
Copy pathDmt.cpp
File metadata and controls
92 lines (79 loc) · 2.23 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
#include <iostream>
#include <string>
using namespace std;
class Person {
protected:
string name;
int id;
public:
Person(string n, int i) {
name = n;
id = i;
}
virtual void showInfo() {
cout << "Name: " << name << " | ID: " << id << endl;
}
};
class DeliveryMan : public Person {
private:
string vehicle;
string location;
public:
DeliveryMan(string n, int i, string v, string loc)
: Person(n, i) {
vehicle = v;
location = loc;
}
void updateLocation(string newLoc) {
location = newLoc;
}
void showInfo() override {
cout << "DeliveryMan: " << name
<< " | Vehicle: " << vehicle
<< " | Location: " << location << endl;
}
};
class Order {
private:
int orderId;
string customer;
string address;
DeliveryMan* deliveryMan;
public:
Order(int oid, string c, string addr, DeliveryMan* dm)
: orderId(oid), customer(c), address(addr), deliveryMan(dm) {
}
void showOrder() {
cout << "Order ID: " << orderId
<< " | Customer: " << customer
<< " | Address: " << address << endl;
cout << "Assigned -> ";
deliveryMan->showInfo();
}
};
int main() {
DeliveryMan dm1("khan", 101, "Bike", "Nilore");
DeliveryMan dm2("Sajid Khan", 102, "Car", "Ithehad Town");
DeliveryMan dm3("Bilal Ahmed", 103, "Scooter", "Leathrar Road");
DeliveryMan dm4("Usman Tariq", 104, "Van", "Thanda Pani");
DeliveryMan dm5("Hamza Yousaf", 105, "Truck", "Bahria Town");
Order o1(1, "Sajal Tariq", "Nilore", &dm1);
Order o2(2, " Ali Raza ", "Leathrar Road", &dm2);
Order o3(3, "Fatima Noor", "Thanda Pani", &dm3);
Order o4(4, "Zain Malik", "Bahria Town", &dm4);
Order o5(5, "Ayesha Khan", "I-8 Islamabad", &dm5);
cout << "--- Delivery Orders ---\n";
o1.showOrder();
cout << "-----------------------\n";
o2.showOrder();
cout << "-----------------------\n";
o3.showOrder();
cout << "-----------------------\n";
o4.showOrder();
cout << "-----------------------\n";
o5.showOrder();
dm1.updateLocation("Abasyn University");
cout << "\nAfter Location Update:\n";
o1.showOrder();
return 0;
}