QuestionQuestion

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

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.
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"

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include <iostream>

using namespace std;

class Vehicle {
public:
    Vehicle(string medium);
    virtual ~Vehicle();
    virtual void steer() = 0;
    virtual void accelerate() = 0;
    virtual void brake() = 0;
    string getMedium();
    void printDirections();
protected:
    string direction[4];
    string medium;
};

/**
* construtor
* @param medium
*/
Vehicle::Vehicle(string medium) {
    this->medium = medium;
}

/**
* destructor
*/
Vehicle::~Vehicle() {

}

/**
*
* @return medium
*/
string Vehicle::getMedium() {
    return medium;
}

/**
* print all directions
*/
void Vehicle::printDirections() {
    for (int i = 0; i < 4; i++) {
       cout << direction[i] << " ";
    }
    cout << "\n";
}

class Boat : public Vehicle {
public:
    Boat();
    ~Boat();
    void accelerate() override;
    void brake() override;
    void steer() override;
};...

By purchasing this solution you'll be able to access the following files:
Solution.cpp.

$28.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats