Question: C++ Given two classes: Plane and Boat that share common methods (add,remove) of adding and removing passengers, and the following characteristics that are distinct to

C++

Given two classes: Plane and Boat that share common methods (add,remove) of adding and removing passengers, and the following characteristics that are distinct to each object:

each has their own method to steer; Bank, Tack

each has their own medium used for travel: Air, Sea

each with their own method to accelerate: jetThrust, setSails

each with their own method to brake: wingFlap, furlSails

each has their own sense of direction:

Plane: Nose, Tail, Left, Right

Boat: Bow, Stern, Port, Starboard

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.

The test of your BoatPlane class should invoke the functions to accelerate, steer, brake, and stop. Each function should simply print out a label of which method is being used: for example when you have a Boat object, accelerate() should print "setSails". When you have a PlaneBoat object accelerate() should print "jetThrust"

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 Databases Questions!