Vla_DOS

Untitled

Sep 14th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>  // SetConsoleCP, SetConsoleOutputCP
  3.  
  4. using namespace std;
  5. #define і i
  6.  
  7. class Time {
  8. private:
  9.     int hour, minute, second;
  10.  
  11. public:
  12.  
  13.     Time(int h, int m, int s) {
  14.         if (h > 0 && h <= 24 && m > 0 && m <= 64 && s > 0 && s <= 60) {
  15.             hour = h;
  16.             minute = m;
  17.             second = s;
  18.         }
  19.         else {
  20.             hour = 0;
  21.             minute = 0;
  22.             second = 0;
  23.             cout << "Не правильно заданий час!";
  24.         }
  25.     }
  26.  
  27.     void Get() {
  28.         cout << "Hour - " << hour << ". Minute - " << minute << ". Second - " << second << endl;
  29.     }
  30.  
  31.     void UpTime(int time) {
  32.        
  33.         hour+= time;
  34.         minute+= time;
  35.         second+= time;
  36.     }
  37.  
  38. };
  39.  
  40. int main() {
  41.     SetConsoleCP(1251);
  42.     SetConsoleOutputCP(1251);
  43.  
  44.     Time t = Time(7, 5, 6);
  45.     t.Get();
  46.     int time;
  47.     cout << "На скільки збільшити час: ";
  48.     cin >> time;
  49.     t.UpTime(time);
  50.     t.Get();
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment