CS 372 Throttle Class Overload
Create the “throttle” class as shown in the text with
a. data members of “position” and “Top_Position” (maximum throttle position)
b. Default “constructor” with two arguments The first sets the “Top_position” and the second sets the current “position”. The third is a copy constructor Ex declaration:
throttle car – set Top_Position to 6 and current to 0
throttle truck(30) – sets Top_position to 30 and current position to 0
throttle shuttle(20,6) – sets Top_position to 20 and current position to 6
throttle mythrottle(truck) -sets/initilizes obj mythrottle to the same values of obj truck
c. Add a member function that will “compare” two throttles using the ‘==’ symbol.
ex if ( car = truck ) … Implement the ‘==’ member function inside the class throttle.
i. To test the above, write code to call the ‘==’ function explicitly ie operator==.
ii. Also code to call the above function using the nice syntax ‘==’.
d. Add the member function ‘!=’ to throttle and implement this function outside the class.
i. To test the above, write code to call the ‘!=’ function explicitly ie operator!=.
ii. Also code to call the above function using the nice syntax ‘!=’.
e. Write an overloaded output function (<<) to print out an object throttle showing the Top_position and the current position.
f. Write a main program that will test the above implementation of throttle that will convince me your throttle class is correct. (ie all methods work.)
There are no reviews yet.