Hello I was wondering if anyone could help me with this programming assignment i
ID: 3785432 • Letter: H
Question
Hello I was wondering if anyone could help me with this programming assignment in C++. Thanks in advance! :
Following the class diagram shown below, create the ExerciseBike class. An ExerciseBike represents a stationary bicycle. Please review the class and the sample driver code.
Note that there is a specific order to the way the class methods should be called. In other words, you can't start pedaling unless you actually got onto the bicycle first. You also can't set a desired level or time to ride unless you have started pedaling first. You can't get off the bike until you stop first. Your class should enforce these rules and write errors to cout as they occur.
A sample driver for this class is shown below. Each exercise bike request should display a single line of output as shown below. You should probably create a more complete driver to test your class.
ExerciseBike
ExerciseBike( );
void getOn( );
void startPedaling( );
bool isBeingPedaled( );
void setLevel( int level );
void setTime( int minutesToRide );
void ride( int minutes );
void stop( );
void getOff( );
bool my_isOn;
bool my_isBeingPedaled
int my_Level;
int my_Time;
int my_TimeRiddenSoFar;
Sample Driver Code
cout << "--Test 1--" << endl;
ExerciseBike b;
b.getOn( );
b.startPedaling( );
b.setLevel( 10 );
b.setTime( 10 );
b.ride( 10 );
b.stop( );
b.getOff( );
cout << "--Test 2--" << endl;
ExerciseBike bad1;
bad1.startPedaling( );
cout << "--Test 3--" << endl;
ExerciseBike bad2;
bad2.getOn( );
bad2.startPedaling( );
bad2.getOff( );
cout << "--Test 4--" << endl;
ExerciseBike bad3;
bad3.getOn( );
bad3.setLevel( 10 );
cout << "--Test 5--" << endl;
ExerciseBike bad4;
bad4.stop( );
Sample Driver Output
--Test 1--
someone got on the bike...
someone started pedaling...
level set to 10
time to ride set to 10
someone has ridden 10 minutes...
someone has stopped pedaling...
someone has gotten off the bike...
--Test 2--
you can't start pedaling until you get on first!
--Test 3--
someone got on the bike...
someone started pedaling...
you can't get off the bike until you stop pedaling!
--Test 4--
someone got on the bike...
you can't set a level until you start pedaling!
--Test 5--
you can't stop pedaling until you start pedaling first!
ExerciseBike
ExerciseBike( );
void getOn( );
void startPedaling( );
bool isBeingPedaled( );
void setLevel( int level );
void setTime( int minutesToRide );
void ride( int minutes );
void stop( );
void getOff( );
bool my_isOn;
bool my_isBeingPedaled
int my_Level;
int my_Time;
int my_TimeRiddenSoFar;
Sample Driver Code
cout << "--Test 1--" << endl;
ExerciseBike b;
b.getOn( );
b.startPedaling( );
b.setLevel( 10 );
b.setTime( 10 );
b.ride( 10 );
b.stop( );
b.getOff( );
cout << "--Test 2--" << endl;
ExerciseBike bad1;
bad1.startPedaling( );
cout << "--Test 3--" << endl;
ExerciseBike bad2;
bad2.getOn( );
bad2.startPedaling( );
bad2.getOff( );
cout << "--Test 4--" << endl;
ExerciseBike bad3;
bad3.getOn( );
bad3.setLevel( 10 );
cout << "--Test 5--" << endl;
ExerciseBike bad4;
bad4.stop( );
Sample Driver Output
--Test 1--
someone got on the bike...
someone started pedaling...
level set to 10
time to ride set to 10
someone has ridden 10 minutes...
someone has stopped pedaling...
someone has gotten off the bike...
--Test 2--
you can't start pedaling until you get on first!
--Test 3--
someone got on the bike...
someone started pedaling...
you can't get off the bike until you stop pedaling!
--Test 4--
someone got on the bike...
you can't set a level until you start pedaling!
--Test 5--
you can't stop pedaling until you start pedaling first!
Explanation / Answer
Here is the code.It's exactly as per the rules. I hope my answer helped you.Any further doubts ,please feel free to contact us.We will love to help you
OUTPUT:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.