QuestionQuestion

Purpose. Build a Boat and set off for a round trip to the Catalina Island. You also need to get back with all crew members accounted for.

Problem: You need to start from the class Boat and build PowerBoat and SailBoat. You will also have a CoastGuardBoat, but it is only if you want to get extra credit to earn qualification points for the complexity level. Each Boat, regardless of whether it is PowerBoat or SailBoat has a motor, and the water tank and the fuel tank (which are the separate classes). Power Boat has an additional motor. Sail Boat has a main sail and may or may not have a spinnaker. Each boat can develop leaks with unknown at the compile time rate. If leak is detected during your trip, you need to activate an electric pump. If that is not enough, you may need to assign a crew member to pump water out with the manual pump. For that (and other) reason, you should have a warning feature that you cannot set for a boat trip, if there is less than 2 people on board. You may however, overwrite that feature, but then if you need to call a Coast Guard and they cannot get to you in time, you are in the water... Coast Guard's rescue operation consists of taking all the people from your boat to their boat. You need to think, what happens if your boat has more people than their maximum capacity.

Note, that you should not allow for a boat self-rescue. Nor your boat, not a Coast Guards'. Think, how you will implement this (if you allow for the self-rescue, you may risk losing those extra points).

You start your trip by starting the motor (on a sail boat), then when you are in the open sea, stop the motor and raise the main sail and spinnaker (if available). Assume that it is about 0.5 - 1 miles before you can get to the high sea.

When you are at a bay, your speed cannot be higher than 5 knots. When you sail, your speed is probably no more than 5 knots (you probably do not want to sail at a high winds anyways). So, it takes a day to get to the Catalina Island and another day to get back. Ideally, you want to refresh your water tank and refill your gas tank on an island before going back.

When you are back, you need to submit the log of your trip.

Method: You need to write an implementation of the following classes (with any additional enhanced functionalities as you may want to).

class Tank
{
public:
                        const float getCapacity();
                        float getMeter();
                        bool isEmpty();
                        void refill();
                     protected:
                        Tank(float);
                        ~Tank(){}
                        float capacity;
                        float meter;
                     private:
                        Tank(){}
};

lass FuelTank : public Tank
{
public:
      friend class Motor;
      FuelTank(float);
      ~FuelTank(){}
      void refuel();
   private:
      FuelTank() : Tank(0) {}
};

class WaterTank : public Tank
{
public:
      WaterTank(float);
      ~WaterTank(){}
      void flush();
   private:
      WaterTank(): Tank(0){ }
};

class Motor
{
public:
    enum Status {NOT_RUNNING, RUNNING};
    Motor(int strokes, int hPowers);
    ~Motor(){}
    void start();
    void stop();
    Status getStatus(){return status;}
    int getStrokes(){return numStrokes;}
    int getHorsePower(){return horsePower;}
   private:
    Motor(){}
    Status status;
    int numStrokes;
    int horsePower;
};


class Pump
{
protected:
      Pump(float rate);
      Pump() : rate(0) {}
      virtual ~Pump(){}
      virtual void pump(Boat &) = 0;
      const float rate;
};

class ElectricPump : public Pump
{
public:
      ElectricPump();
      virtual ~ElectricPump(){}
      virtual void pump(Boat &);
};

class ManualPump : public Pump
public:
ManualPump();
virtual ~ManualPump(){}
virtual void pump(Boat &);
};
class CoastGuardBoat;

class Boat
{
public:
      void startMotor();
      void stopMotor();
      void people(int);
      void pumpWater(float);
      bool isLeaking();
      float leakingRate();
      void SOS();
   protected:
      friend class CoastGuardBoat;
      Boat(int numstrokes, int hPower, float water_capacity,
                float fuel_capacity,
                  int size, int speed, int people);
      ~Boat(){}
      bool canStart();
      int getPeople();
      int getMaxSpeed();
      int getSize();
      WaterTank wTank;
      FuelTank fTank;
      Motor motor;
      int size;
      int numPeople;
      int peopleCapacity;
      int maxSpeed;
      float water_in;
   private:
      Boat() : wTank(0), fTank(0), motor(0, 0){}
};
class SailBoat : public Boat
{
public:
      enum Sail {SAIL_RAISED = 1, SAIL_LOWERED = 2,
            SPINNAKER_RAISED = 4, SPINNAKER_LOWERED = 8};
      SailBoat(int numstrokes, int horses, float water_capacity,
                float fuel_capacity,
                int size, int speed,
                int people, bool has_spinnaker);
      ~SailBoat(){}
      bool hasSpinnaker();
      void raiseMainSail();
      void raiseSpinnaker();
      void lowerMainSail();
      void lowerSpinnaker();
   private:
      bool spinnaker;
      Sail sail;
};

class PowerBoat : public Boat
                  {
                     public:
                        PowerBoat(int numstrokes, int hPower, float water_capacity,
                                    float fuel_capacity,
                                  int size, int speed, int people);
                        ~PowerBoat(){}
                        void startMotor();
                        void stopMotor();
                     private:
                        Motor secondMotor;
                  };
                  enum CoastGuardType {LITORAL, OPENSEA};
                  class CoastGuardBoat : public PowerBoat
{
public:
                        CoastGuardBoat(CoastGuardType);
                        ~CoastGuardBoat(){}
                        void rescue(Boat &);
};

When you write your program, do NOT wait until you complete it before you start compiling and testing it. Ideally, with each group of classes you complete, write an interface stab and a short driver program to test. I want to see at least two or three such development iterations when you submit your completed project. There are some things here that we have not covered yet. Do not wait for them. Start with what you already know. You already should be able to write most of the code.

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.

/*
* File:   Your_Initils_Boat.h
* Author:
*
*
*/

#ifndef Your_Initils_Boat_H
#define Your_Initils_Boat_H

#include <fstream>
using namespace std;

class Tank {
public:
    const float getCapacity();
    float getMeter();
    bool isEmpty();
    void refill(fstream & out);
protected:
    Tank(float);

    ~Tank();
    float capacity;
    float meter;
private:

    Tank();
};

class FuelTank : public Tank {
public:
    friend class Motor;
    FuelTank(float);

    ~FuelTank(){
    }
    void refuel(fstream & out);
private:

    FuelTank() : Tank(0) {
    }
};

class WaterTank : public Tank {
public:
    WaterTank(float);

    ~WaterTank(){
      
    };
    void flush(fstream & out);
private:

    WaterTank() : Tank(0) {
    }
};

class Motor {
public:

    enum Status {
       NOT_RUNNING, RUNNING
    };
    Motor(int strokes, int hPowers);

    ~Motor() {
    }
    void start(fstream & out);
    void stop(fstream & out);

    Status getStatus() {
       return status;
    }

    int getStrokes() {
       return numStrokes;
    }

    int getHorsePower() {
       return horsePower;
    }
private:

    Motor() {
    }
    Status status;
    int numStrokes;
    int horsePower;
};...

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

$78.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