Question
C++ Program Create the throttle class as shown in the text with the addition of a Top Position or some people call it the Max
C++ Program
Create the "throttle" class as shown in the text with the addition of a Top Position or some people call it the Max Position member variable. Default to 6.
class throttle
{
public:
void shut_off( );
void shift(int amount);
double flow( ) const;
bool is_on( ) const;
private:
int position;
};
a. data members: 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".
Example declaration, show more for your testing:
throttle car - set Top_Positon 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
Now to test your code: You will write your own main program that will test all the methods in your classes (Throttle). Show that ALL methods work correctly. Your output should be something like the following:
Testing shut_Off method:
throttle currently at 4
call shut_Off
throttle currently at 0
call shut_Off
throttle currently at 0 (Note: verifies that throttle at 0 stays at 0)
Testing shift method: (Note: testing all possibilities)
Throttle currently at 4
Call shift +2
Throttle currently at 6
Call shift -3
Throttle currently at 3
Call shift +5
Throttle currently at 6 (Note; 6 is the max)
Call shift -9
Throttle currently at 0 (Note: cannot go below 0)
etc..
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started