Question
Picture a car dealership. There are many different types of vehicles for sale. The salespeople know every detail about every one. But the accountants inside
Picture a car dealership. There are many different types of vehicles for sale. The salespeople know every detail about every one. But the accountants inside only care that a vehicle is getting sold. Model this system:
The dealer sells Hatchbacks and Sedans
These both inherit from Vehicle, and Vehicle cannot have properties. It can have methods, virtual methods, or pure virtual methods.
Every vehicle has a price
Hatchbacks have 5 doors and sedans have 4
Every vehicle has a trunk. A hatchback holds 30 cu ft, a sedan 20
Lastly, every vehicle can be started
Make two functions that take a Vehicle pointer as an argument*. Call one Salesperson and the other Accountant.
void Salesperson(Vehicle* tWhat);
void Accountant(Vehicle* tWhat);
The salesperson function:
Prints the type of car
Prints how many doors it has
Prints the trunk size
Starts the car
The Accountant function:
Prints the price
If these functions were in a class, they'd be methods. No Sales or Accountant classes.
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