Advertisement
TheWhiteFang

Untitled

Nov 30th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. class Time{
  6.  
  7. public:
  8.  
  9. int min;
  10. int hour;
  11.  
  12. Time(int min = 0, int hour = 0){
  13.  
  14.  
  15.  
  16. if (min >= 0) {
  17. if (min > 59) { min = 0; }
  18. }
  19. else{ min = 0; }
  20.  
  21. if (hour >= 0) {
  22. if (hour > 23) { hour = 0; }
  23. }
  24. else { hour = 0; }
  25. }
  26.  
  27. int setTime(int x, int y){
  28. min = x;
  29. hour = y;
  30.  
  31. if (x >= 0) {
  32. if (x > 59) { min = 0; }
  33. }
  34. else{ min = 0; }
  35.  
  36. if (y >= 0) {
  37. if (hour > 23) { hour = 0; }
  38. }
  39. else { hour = 0; }
  40.  
  41. return min, hour;
  42.  
  43. }
  44.  
  45. void showTime(){
  46. cout << setfill('0');
  47. cout << setw(2) << hour << ":" << setw(2) << min << endl;
  48.  
  49. }
  50.  
  51. Time copyTime(Time x){
  52.  
  53. }
  54.  
  55. };
  56.  
  57.  
  58.  
  59.  
  60. int main(){
  61.  
  62. Time t1;
  63. t1.setTime(2, 3);
  64. t1.showTime();
  65.  
  66.  
  67.  
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement