Question: 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

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!