Answer:
See explaination
Step-by-step explanation:
Program source code below.
#include "Motorcycle.cpp"
#include <iostream>
using namespace std;
int main()
{
Motorcycle motorcycleOne,motorcycleTwo;
motorcycleOne.setSidecar(true);
motorcycleTwo.setSidecar(false);
motorcycleOne.setMaxSpeed(90);
motorcycleTwo.setMaxSpeed(85);
motorcycleOne.setSpeed(65);
motorcycleTwo.setSpeed(60);
motorcycleOne.accelerate(30);
motorcycleTwo.accelerate(20);
cout<<"MotorcycleOne speed:"<< motorcycleOne.getSpeed()<<endl;
cout<<"MotorcycleTwo speed:"<< motorcycleTwo.getSpeed()<<endl;
if(motorcycleOne.getSidecar())
cout<<"MotorcycleOne has a sidecar"<<endl;
else
cout<<"MotorcycleOne does not have a sidecar"<<endl;
if(motorcycleTwo.getSidecar())
cout<<"MotorcycleTwo has a sidecar"<<endl;
else
cout<<"MotorcycleTwo does not have a sidecar"<<endl;
// Create Motorcyle objects here
// Create a boolean variable for side car status
// Set side car status here
// Set maximum speed here
// Set current speed here
// Accelerate motorcyles here
// Display current speed here
// Determine side car status and display results.
return 0;
}
Motorcycle.cpp
#include "Vehicle.cpp"
#include <iostream>
using namespace std;
class Motorcycle:public Vehicle{
public:
void setSidecar(bool);
bool getSidecar();
void accelerate(double);
private:
bool sidecar;
};
void Motorcycle::setSidecar(bool s){
sidecar=s;
}
bool Motorcycle::getSidecar(){
return sidecar;
}
void Motorcycle::accelerate(double mph)
{
if(getSpeed() + mph < getMaxSpeed())
setSpeed(getSpeed() + mph);
else
cout << "This motorcycle cannot go that fast." << endl;
}