Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

Students also viewed these Databases questions

Question

2. Provide recommendations for effective on-the-job training.

Answered: 1 week ago