Sample Question
Sample Question
Imagine that you’re creating a logistics management application. The first version of
your app can only handle transportation by trucks, so the bulk of your code lives
inside the Truck class. Currently your code-base looks like the following:
#include <iostream>
#include <string>
class Transport
public:
};
public:
};
class RoadLogistic
public:
string result = "Your goods and products are shipped now ----- \n" +
transport->Delivery();
return result;
};
public:
};
cout << "Don't worry about your products and the transportation\n"
int main()
ClientCode(*logistic1);
Current Output:
After a while, your app becomes pretty popular. Each day you receive dozens of requests
from sea and plane transportation companies to incorporate sea and air logistics into the app.
Great news, right? But how about the code? At present, most of your code is coupled to the
Truck class. Adding Ships and Plane into the app would require making changes to the entire
code-base. Moreover, if later you decide to add another type of transportation to the app, you
will probably need to make all of these changes again. Which design pattern can we use to
solve this problem and our progarm output will be looking like the following:
Expected Output:
----------------------------------
------------------------------------
--------------------------------------