Question: Hello I need help with my C++ program. I need to change the part highlighted in bold to the part described below: This part needs

Hello I need help with my C++ program. I need to change the part highlighted in bold to the part described below:

This part needs to be added:

int main() { Car tesla(2019, "S3"); cout << "My Tesla is at " << tesla.getSpeed() << " m/h. "; for( int count =0; count < 10; count++ ) { tesla.accelerate(); cout << "My Tesla is at " << tesla.getSpeed() << " m/h. ";

Car.h

#pragma once #include

using namespace std;

class Car { private: int yearModel; int speed = 0; string make;

public: Car(int year, string m) { speed = 0; yearModel = year; make = m; }

void setYearModel(int); void setSpeed(int); void setMake(string);

int getYearModel() const; int getSpeed() const; string getMake() const;

void accelerate(); //add 5 to speed void brake(); //subtract 5 to speed };

testCar.cpp

#include "Car.h" #include #include

using namespace std;

void Car::setYearModel(int ym) { yearModel = ym; }

void Car::setSpeed(int sp) { speed = sp; }

void Car::setMake(string m) { make = m; }

int Car::getYearModel() const { return yearModel; }

int Car::getSpeed() const { return speed; }

string Car::getMake() const { return make; }

void Car::accelerate() { speed += 5; }

void Car::brake() { speed -= 5; }

int main() { //This part needs to be changed for the part described above in bold unique_ptr testCar(new Car(2019, "Tesla"));

cout << "Current speed: " << testCar->getSpeed() << endl;

//calls accelerate and dispalys its 5 times for (int i = 0; i < 5; i++) { cout << "Accelerating..." << endl; testCar->accelerate(); cout << "Current speed: " << testCar->getSpeed() << endl; }

//calls brake and dispalys its 5 times for (int i = 0; i < 5; i++) { cout << "Braking..." << endl; testCar->brake(); cout << "Current speed: " << testCar->getSpeed() << endl; }

return 0;

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!