15 Points
The objective of this assignment is for you to learn to correctly
define a class, implement methods, and and test the defined class.
We will work on this in class.
Define a class named Treadmill that contains the appropriate data
members and methods.
The class must have these private data members
- Speed (double)
- Incline (double)
- Calories Burned (integer)
The class must have these public methods
- void setSpeed (double)
- double getSpeed ()
- void setIncline (double)
- double getIncline ()
- void setCaloriesBurned (integer)
- int getCaloriesBurned ()
- void printTreadMill()
Compare the format of your code to rational
number code
In addition, these constructors must be provided:
- Three parameters to set speed, incline, and calories burned
- Two parameters to set speed and incline
- 0 parameters to set all data members to 0
In order to test your class, create a main with three
test treadmills:
- treadMill T1, t2(3.5, 12.6), T3(4.1, 8.2, 150)
- print the values for each of the three treadmills to "prove" the instiantiation works
- Next, test each of the set and get methods by calling them for a treadmill.
For example:
- T1.setIncline(7.50);
- T1.setCaloriesBurned(240);
- T1.setSpeed (6.2);
- Invoke the print method for T1
- Another example for T2 that uses treadmill 1 and treadmill 3
- T2.setIncline(T1.getIncline());
- T2.setCaloriesBurned(T3.getCaloriesBurned());
- T2.setSpeed (T1.getSpeed());
- Invoke the print method for T2
Output from printTreadmill should include the 3 data members
- Speed
- Incline
- Calories Burned
with associated
verbage.
For example:
Treadmill with maximum speed of 7.5 mph and maximum incline of 12.5
Client has burned 100 calories
To hand in this assignment:
- Place the .cpp code in the dropbox named Treadmill
- Place the output (.txt) of the program also in the dropbox named Treadmill