Question: URGENT C++ problem, You are going to create a Car class (must have a header file and an implementation file). The Car class has the

URGENT C++ problem,

You are going to create a Car class (must have a header file and an implementation file). The Car class has the following variables:

  • string make
  • string model
  • unsigned int year
  • string color
  • unsigned int speed

A Car can perform the following actions:

  • void brake() : Decreases speed by 2. Speed can never be negative, so 0 is the smallest value that speed can have.
  • void accelerate() : Increases speed by 2
  • void stop() : set's speed to 0
  • void print_speed() : Displays the speed as mph. Example: "35 mph"
  • print_car() : Prints all of the Car's information, including its current speed.
  • Car(string init_color, string init_make, string init_model, unsigned int init_year): This constructor initializes speed to 0 and the other parameters accordingly to the input parameters.
  • Car() : The overloaded default constructor initializes speed to 0 and all string variables to an empty string. year is initialized to 1886.

Main Program Instructions

In your driver file (main.cpp), create a Car object. You may initialize the object with whatever information you want. Call accelerate() twice, then call the print_car(). Call the brake() function once and then call the print_car() function again.

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!