Description
Write a Scooter class that has the following private member variables:
Variable Name | Description |
type | A string that holds the brand and model of the scooter. |
max_speed | An float that holds the maximum speed for the scooter. |
current_speed | A float that holds the current charge as a percentage. |
In addition, the class should have the following constructors and member functions:
- Default Constructor: The constructor should create an empty Scooter object, set the name to the empty string, and max and current speed to 0.
- 2nd Constructor: The second constructor should accept the scooter’s name and max speed as arguments. It should create an object with the requested name and max speed, setting the current speed to 0.
- Accessors: Appropriate accessor functions to return the values stored in an object’s member variables.
- Mutators: Appropriate mutator functions to set the values stored in an object’s member variables. Validate the data as is appropriate for the field
- speedUp: Increase speed by 2 mph, up to max_speed.
- slowdown: Decrease speed by 3 mph, down to 0.
Demonstrate the class in a program (main) that creates a scooter object, uses a loop to increase the speed in increments of 2 mph until reaching the max speed, printing the current speed after each increment. Then use a second loop to decrease the speed by decrements of 3 mph down to 0, printing speed after each increment.
Design your class and program by completing the CS 250 OOP Design Document. Give the class declaration, including member variables and function prototypes. Also include a brief description of what is to be stored in each member variable and the purpose of each member function. Then give a description of what the main program will do. You’ll need to include time estimates for design, coding each function, program testing, and total time.
Save the design in a file named ScooterDesign_xxx.doc where xxx are your initials. Submit your program design in the Program 7 Design drop box by the due date shown in the calendar and drop box tools.
Write your class and program.
Save your class declaration in a file named Scooter.h. Save your non-in-line member functions in a file named Scooter.cpp. Save your main program in a file named program7_xxx.cpp where xxx are your initials.
Compile, run and test your program and class using the directions in the Ch 13 notes.
Update your Program Design Document. Update the class and program descriptions to fit your working program. Update the time estimates based on actual time spent.
Submit your updated design document and working .h and .cpp files in the Program 7 drop box. You should submit 4 files in the program drop box.