Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++!!!!!!!!! Inherited Class We do not have to encode all elements (i.e. member functions) in a class. Suppose that we wish to have a customized

C++!!!!!!!!!

Inherited Class

We do not have to encode all elements (i.e. member functions) in a class. Suppose that we wish to have a customized class with a set of basic member functions but with an additional series of other member functions? This is a inherited or derived class.

A child class inherits one or more common characteristics from a base or parent class. That child class can use one or more of the functions from that parent PLUS any additional member functions in its own class. The child class can even include member variables NOT in its parent class.

1.Create a base (parent) class called Vehicles with the following member variables:

a)String vehicle name

b)Integer number of passengers including the driver)

c)Integer number of wheels on the vehicle (i.e. zero to N)

d)Float maximum Miles Per Hour, speed

2.The Vehicle parent class member functions:

a)Set the vehicle name

b)Set the number of passengers

c)Set the number of wheels

d)Set the maximum Miles Per Hour, speed

e)Retrieve the vehicle name

f)Retrieve the number of passengers

g)Retrieve the number of wheels

h)Retrieve the maximum speed of the vehicle

i)Set all of the member variable data (pass string, integer, integer, float variables representing the vehicle name, number of passengers, number of wheels, maximum speed)

j)Constructor Set a default of Motorcycle, 2 passengers, 2 wheels, maximum speed of 100 MPH

3.Create a child class called Trucks with the following member variables:

a)Float load (maximum carrying capacity in pounds)

b)Float weight (weight of the Truck class member in pounds)

4.Truck member functions:

a)Set the load of the vehicle

b)Set the weight of the vehicle

c)Retrieve the load

d)Retrieve the weight

e)Constructor Set a default load of zero and a weight of 2000 lbs

5.Application will perform the following:

a)Use an array to hold Vehicle class members and another array for the child class members (at least 10 for demonstrations sake)

b)Initialize vehicles to:

1)Sedan, 5 passengers, 4 wheels, 80 MPH

2)Bicycle, 1 passenger, 2 wheels, 30 MPH

3)Unicycle, 1 passenger, 1 wheel, 15 MPH

4)Row Boat, 3 passengers, 0 wheels, 10 MPH

c)Initialize two Truck members:

1)Pickup Truck, 2 passengers, 4 wheels, 65 MPH

2)Van, 2 passengers, 6 wheels, 70 MPH

d)Allow the application to

1)Display all Vehicle class members values

2)Change a Vehicle class members values based on its array index location

3)Find a Vehicle class member based on its array index location

4)Display the Truck class member values

5)Set the Truck member values of Load and Weight

6)Quit this application

Output Example:

1 - Display All Vehicles

2 - Change Values of a Class Member

3 - Find a Vehicle Class Member

4 - Display Truck Values

5 - Change Truck Members

6 - Quit

Enter an Option 1 - 6: 1

Index #0

Sedan Carries 5 Passengers (Including the driver)

Sedan Has 4 Wheels and can travel a Maximum of 95 mph

Index #1

Bicycle Carries 1 Passengers (Including the driver)

Bicycle Has 2 Wheels and can travel a Maximum of 20 mph

Index #2

Uncycle Carries 1 Passengers (Including the driver)

Uncycle Has 1 Wheels and can travel a Maximum of 10 mph

Index #3

Row Boat Carries 3 Passengers (Including the driver)

Row Boat Has 0 Wheels and can travel a Maximum of 10 mph

Index #4

Motorcycle Carries 2 Passengers (Including the driver)

Motorcycle Has 2 Wheels and can travel a Maximum of 100 mph

Hit Any Key to continue...

3 - Find a Vehicle Class Member

Enter an Index 0 to 4: 1

Index #1

Bicycle Carries 1 Passengers (Including the driver)

Bicycle Has 2 Wheels and can travels a Maximum of 20 mph

Hit Any Key to continue...

4 - Display Truck Values

Pickup weighs 2000 pounds and carries a Load of 0 pounds

Pickup has 4 Wheels and carries 2 passengers

Pickup has a maximum speed of 75 mph

Van weights 2000 pounds and carries a Load of 0 pounds

Van has 6 Wheels and carries 2 passengers

Van has a maximum speed of 65 mph

Hit Any Key to continue...

5 - Change Truck Members

1 - Change Trucks Values

2 - Cancel

Find Vehicle Index: 0

1 of 4 - Set the Weight of the Pickup: 3500

2 of 4 - Set the Maximum Load of the Pickup: 2500

3 of 4 - Set the Number of Wheels on the Pickup: 4

4 of 4 - Set the Maximize Speed of the Pickup: 75

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

Step: 3

blur-text-image

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions