Question: Available from: Monday, 2 December 2 0 2 4 , 1 2 : 0 0 AM Due date: Saturday, 1 4 December 2 0 2
Available from: Monday, December : AM
Due date: Saturday, December : PM
D Requested files: BoatPlane.h BoatPlane.cpp boldsymboldownarrow Download
C Maximum number of files:
Type of work: mathbf Individual work
The goal of this program is to create a class hierarchy to instantiate objects that can have one of two specific behaviors: It can be a boat, or it can be a plane.
I need an object that can behave like a Plane or a Boat. We will use inheritance to share common methods:
add add passengers to the vehicle
remove remove passengers from the vehicle
We will use polymorphic functions to have the object print out a different string depending on whether it is a Boat object or a Plane object. These functions are:
steer change direction
travel indicate what medium it travels through
accelerate increase velocity rate of motion
brake decrease velocity. The instantiated object will print a different message when each of the functions above are invoked.
steer A boat will print "Tack" a plane will print "Bank"
travel a boat will print "Sea" a plane will print "Air"
accelerate a boat will print "setSails" a plane will print "jetThrust" jetThrust, setSails
brake a boat will print "furlSails" a plane will print "wingFlaps"
In addition each object will print their own sense of direction when turning:
Plane can bank Left or Right
A Boat can tack to Port or Starboard
To write this program you must:
Create an abstract class Vehicle that has the methods common to all classes.
Create a derived class Boat that inherits from Vehicle and has the appropriate fields and functions.
Create a derived class BoatPlane that inherits from Boat that adds the appropriate fields and overloads the appropriate functions. A BoatPlane should be able to distinguish whether it is traveling as a Plane or a Boat.
In your main function exercise all functions of the class in the following manner:
add passengers.
remove passenger
travel
accelerate
steerleft and steerright
brake
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
