Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. class Stop
  2. {
  3. bool isRunning;
  4. clock_t time1;
  5. clock_t time2;
  6. double seconds;
  7.  
  8. public:
  9. //Construct and initialise
  10. Stop();
  11. //Return current time of stopwatch
  12. void getTime();
  13. //Press button 1 to start or stop counting
  14. void pushButtonStartStop();
  15. //Press button 2 to reset time
  16. void pushButtonReset();
  17. };
  18.  
  19. void Stop::pushButtonStartStop()
  20. {
  21. if(isRunning == false)
  22. {
  23. isRunning = true;
  24. time1 = clock();
  25.  
  26. }
  27. else
  28. {
  29. isRunning = false;
  30. time2 = clock();
  31. seconds += ((double)(time2-time1)/ CLOCKS_PER_SEC);
  32. }
  33. }
  34.  
  35. Stop watch;
  36. watch.pushButtonStartStop();
  37. for(long i = 0; i< 100000000;i++)
  38. {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement