Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started