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, 2 December 2024,12:00 AM
Due date: Saturday, 14 December 2024,11:59 PM
D Requested files: BoatPlane.h, BoatPlane.cpp (\(\boldsymbol{\downarrow}\) Download)
C. Maximum number of files: 5
Type of work: \(\mathbf{9}\) 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:
- add0- add passengers to the vehicle
- remove()- remove passengers from the vehicle
We will use 4 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 4 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:
1. Create an abstract class Vehicle that has the methods common to all classes.
2. Create a derived class Boat that inherits from Vehicle and has the appropriate fields and functions.
3. 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 (3) passengers.
- remove(1) passenger
travel()
accelerate()
steer(left) and steer(right)
brake()
Available from: Monday, 2 December 2 0 2 4 , 1 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!