Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are going to create two classes today. Both classes will be part of the same project/workspace. Class 1: This class is called Car. The
You are going to create two classes today. Both classes will be part of the same project/workspace.
Class 1: This class is called Car. The Car class has the variables:
- make
- model
- year
- color
- speed.
A Car can perform the following actions:
- brake() : Decreases speed by 2. Speed can never be negative, so 0 is the smallest value that speed can have.
- accelerate() : Increases speed by 2
- stop() : set's speed to 0
- print_speed() : Prints out the speed as mph. Example: 35 mph
- print_car() : Prints all of the cars information, including its current speed.
- init_car(string init_color, string init_make, string init_model, int init_year): Initializes speed to 0 and the other parameters accordingly. This function should be called right after Car object is created
Class 2: The second class is called Scooter. A scooter has the variables:
- color
- make
- model
- year
- speed
A Scooter can perform the following functions:
- brake() : Decreases speed by 3 (speed can never be negative).
- accelerate(): Increases speed by 1., or stop.
- print_speed(): Prints out the Scooter's speed.
- print_scooter() : Prints out all of the Scooters information, including its speed.
- stop() : When the Scooter stops, the speed becomes 0.
- init_scooter(string init_color, string init_make, string init_model, int init_year): Initializes speed of the scooter to 0 and the other parameters accordingly.
write in c++
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