Advertisement
Guest User

michal

a guest
Nov 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. #pragma once
  5. class Timer
  6. {
  7. private:
  8. unsigned long start_time;
  9.  
  10. public:
  11. Timer();
  12. void reset(int time_to_add);
  13. bool expired();
  14. };
  15.  
  16. Timer::Timer()
  17. {
  18. this->start_time = clock();
  19. }
  20.  
  21. void Timer::reset(int time_to_add)
  22. {
  23. this->start_time = ((clock() - this->start_time) / (int)CLOCKS_PER_SEC) + time_to_add;
  24. }
  25.  
  26. bool Timer::expired()
  27. {
  28. return ((clock() - this->start_time) / (int)CLOCKS_PER_SEC) > this->start_time;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement