C++ Coding extra credit activity copiable code: #include // OTHER INCLUDES??? using namespace std; // YOUR CODE HERE #include "testcode.h" // For automatic grading purposes DO NOT REMOVE (but you can comment out temporarily for testing) int main() {
C++ Coding extra credit activity
copiable code:
#include <iostream>
// OTHER INCLUDES???
using namespace std;
// YOUR CODE HERE
#include "testcode.h" // For automatic grading purposes DO NOT REMOVE (but you can comment out temporarily for testing)
int main() {
testTimerClass(); // Test code for automatic grading. DO NOT REMOVE (but you can temporarily comment out for your own testing). Remove any test code you may have added prior to final submission.
}
Additional Files: testcode.h and testTimerClass
These files will automatically be compiled with your code. You cannot modify them.
testcode.h
using namespace std;
void testGetTime(){
Timer timer(true);
system("sleep 2");
cout << timer.getTime() << std::endl;
}
void testStartAndStop(){
Timer timer(true);
system("sleep 1");
timer.printTime();
timer.stop();
system("sleep 1");
timer.printTime();
timer.start();
system("sleep 1");
timer.printTime();
timer.stop();
system("sleep 1");
timer.printTime();
}
void testAddTimeToClock(){
Timer timer;
timer.addTimeToClock(60);
cout << timer.getTime() << std::endl;
}
void testReset(){
Timer timer;
timer.addTimeToClock(60);
timer.printTime();
timer.reset();
timer.printTime();
}
void testHoursMinutes(){
Timer timer;
timer.addTimeToClock(90);
timer.printTime();
timer.addTimeToClock(3600 * 2);
timer.printTime();
}
void testTimerClass(){
int testNumber;
cin >> testNumber;
switch (testNumber){
case 1: testStartAndStop(); break;
case 2: testAddTimeToClock(); break;
case 3: testReset(); break;
case 4: testHoursMinutes(); break;
}
}
Step by step
Solved in 2 steps