Question
In C++... 1) Order Class: Your basic Order has a customer number, a customer name. It should have this data private or protected, not public.
In C++...
1) Order Class: Your basic Order has a customer number, a customer name. It should have this data private or protected, not public. It should have public get() and set() functions and a constructor to set its values.
2) PurchaseOrder Class: This Order should inherit from the Order class and also have a Price. It should have public get() and set() functions. It's constructor should take all the values for the new object and call its base class (Order) constructor and pass it the customer number, and customer name before setting the rest of its values.
3) RentalOrder Class: This Order should inherit from the Order class and also have a DaysRented and RentPerDay as variables. It should have public get() and set() functions. It should have public get() and set() functions. It's constructor should take all the values for the new object and call its base class (Order) constructor and pass it the customer number, and customer name before setting the rest of its values.
4) In main, test your two derived classes. Create an object of each with data from the user or hard coded values (your choice.) After both objects are created, use the get() functions to print the data in each object to the console screen.
Part 2: Polymorphism (50 points)
1) Open back up your Order class and make a virtual function called printOrder()
2) Open back up your PurchaseOrder class and make a virtual function called printOrder() which overrides (the chapter calls it redefining) the printOrder() inherited from the Order class. Have this new function print out all of the details of a purchase including customer number, customer name, and Price.
3) Open back up your RentalOrder class and make a virtual function called printOrder() which overrides (the chapter calls it redefining) the printOrder() inherited from the Order class. Have this new function print out all of the details of a car purchase including customer number, customer name along with a Total of DaysRented multiplied by RentPerDay.
4) Test your virtual functions (and demonstrate polymorphism) by making an array of pointers of type Order, creating at least one as a purchase in the array, and at least one other as a rental in the array. Use data from the user or hard coded values in main(), it is your choice to have the data for these objects.
Then use a loop and call printOrder() on each object in the array calling this virtual function polymorphicly for them, showing the mixed orders in one loop.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started