Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. The dealer sells Hatchbacks and Sedans
  2. Every vehicle has a price
  3. Hatchbacks have 5 doors and sedans have 4
  4. Every vehicle has a trunk. A hatchback holds 30 cu ft, a sedan 20
  5. Lastly, every vehicle can be started

Make two functions that take a Vehicle pointer as an argument. Call one Salesperson and the other Accountant.

The salesperson function:

  1. Prints the type of car
  2. Prints how many doors it has
  3. Prints the trunk size
  4. Starts the car

The Accountant function:

  1. Prints the price

If you are looking at this in a panic, stop just looking at. You can see there is a Hatchback class and a Sedan class. They have a lot of similarities so they need a base class. Then just start putting things places. If you find you put the same thing in two classes, move it to the parent.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

identify the main ways in which you learn

Answered: 1 week ago