-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource file
More file actions
112 lines (70 loc) · 1.77 KB
/
source file
File metadata and controls
112 lines (70 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "header.h"
#include <iostream>
using namespace std;
#include <iomanip> // for std::setfill and std::setw
Time::Time(int h,int m) {
cout << "hour value or press 0"<<endl;
cin >>h;
cout << "minute value or press 0"<<endl;
cin >>m;
if((0<=h<=24) & (0<=m<=60)) {
hour = h;
minute = m;
} else {
hour = 0;
minute = 0;
cout<<"incorrect input clock arranged to 00:00"<<endl;
};
};
void Time::increment_minute() {
minute++;
};
void Time::display_time() {
cout << setfill('0') << setw(2) << hour << ":" << setfill('0') << setw(2) << minute << endl;
};
void Time::decrement_minute() {
minute--;
};
void Time::set_minute(int m) {
minute = m;
};
void Time::set_hour(int h) {
hour = h;
};
int Time::get_minute() {
return minute;
};
int Time::get_hour() {
return hour;
};
// TIMEZONE
TimeZone::TimeZone(int h, int m, int t) : Time(h,m), time_zone(t) {
cout<<"give time zone value between -11 and 12"<<endl;
cin >> t;
time_zone= t;
};
void TimeZone::change_time_zone(int new_value) {
int former_time_zone = time_zone;
time_zone = new_value;
change_time_when_zone_changed(former_time_zone , time_zone);
};
void TimeZone::get_time_zone() {
cout<<time_zone<<endl;
};
void TimeZone::display_time_and_time_zone() {
cout<<timezone<<flush;
display_time();
};
void TimeZone::change_time_when_zone_changed(int f,int t) {
int difference = f-t;
int hour_will_be_changed = get_hour();
int minute_will_be_same = get_minute();
int new_hour = hour_will_be_changed-(f-t) ;
string sign;
if(new_hour>=0) {
sign = "+";
} else {
sign = "-";
};
cout<<"GMT"<< t << sign <<new_hour<<":"<<minute_will_be_same<<endl;
};