Respuesta :
Answer:
#include <iostream>
#include <cstring>
#include <cctype>
#include <conio.h>
using namespace std;
class Car
{
private:
int YearModel;
int Speed;
string Make;
public:
Car(int, string);
Car();
string getMake();
int getModel();
int getSpeed();
void Accelerate();
void Brake();
};
Car::Car()
{cout<<"Enter car year: ";
cin>>YearModel;
cout<<"Enter car make: ";
cin>>Make;
Speed=0;
}
Car::Car(int YearofModel, string Makeby)
{
YearModel = YearofModel;
Make = Makeby;
Speed = Spd;
}
//To get who makes the car.
string Car::getMake()
{
return Make;
}
//To get the year of the car.
int Car::getModel()
{
return YearModel;
}
//To holds the car actual speed.
int Car::getSpeed()
{
return Speed;
}
//To increase speed by 5.
void Car::Accelerate()
{
Speed = Speed +5;
cout<<"The "<<YearModel<<" "<<Make<<" is accelerating. The speed is now "<<Speed<<" mph."<<endl;
}
//To drop the speed of the car by 5.
void Car::Brake()
{
Speed = Speed -5;
cout<<"The "<<YearModel<<" "<<Make<<" is braking. The speed is now "<<Speed<<" mph."<<endl;
}
int main()
{
int Speed = 0; //Start Cars speed at zero.
int index;
int total=0;
Car mine;
mine.Accelerate();
mine.Brake();
cout<<"Your Caprice's speed is: "<<Speed<<endl;
Car first( 1990, "Chevy", Speed);
total+=Speed;
//Display the menu and get a valid selection
for(index=0;index<6;index++)
{
first.Accelerate();
// here u have to change Speed to //first.getSpeed()
}
for(index=0;index<6;index++)
{
first.Brake();
// here u have to change Speed to //first.getSpeed()
}
_getch();
return 0;
}