Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h> // SetConsoleCP, SetConsoleOutputCP
- using namespace std;
- #define і i
- class Time {
- private:
- int hour, minute, second;
- public:
- Time(int h, int m, int s) {
- if (h > 0 && h <= 24 && m > 0 && m <= 64 && s > 0 && s <= 60) {
- hour = h;
- minute = m;
- second = s;
- }
- else {
- hour = 0;
- minute = 0;
- second = 0;
- cout << "Не правильно заданий час!";
- }
- }
- void Get() {
- cout << "Hour - " << hour << ". Minute - " << minute << ". Second - " << second << endl;
- }
- void UpTime(int time) {
- hour+= time;
- minute+= time;
- second+= time;
- }
- };
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- Time t = Time(7, 5, 6);
- t.Get();
- int time;
- cout << "На скільки збільшити час: ";
- cin >> time;
- t.UpTime(time);
- t.Get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment