-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime.cpp
More file actions
57 lines (43 loc) · 838 Bytes
/
Time.cpp
File metadata and controls
57 lines (43 loc) · 838 Bytes
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
/*
Time.cpp
Teng Zhao: 40089560
Thomas Flynn: 40034877
*/
#include"Time.h"
Time::Time() {
hour = 0;
minute = 0;
second = 0;
}
Time::Time(int& a, int& b, int& c) {
hour = a;
minute = b;
second = c;
}
Time::Time(const Time&Time) {
hour = Time.hour;
minute = Time.minute;
second = Time.second;
}
Time::Time(int h, int m, int s) {
hour = (h >= 0 && h <= 24) ? h : 0;
minute = (m >= 0 && m <= 60) ? m : 0;
second = (s >= 0 && s <= 60) ? s : 0;
}
void Time::setTime(int h, int m, int s) {
hour = (h >= 0 && h <= 24) ? h : 0;
minute = (m >= 0 && m <= 60) ? m : 0;
second = (s >= 0 && s <= 60) ? s : 0;
}
void Time::printTime() {
cout << " " << hour << ":" << minute << ":" << second << " ";
}
int Time::getHour() {
return hour;
}
int Time::getMinute() {
return minute;
}
int Time::getSecond() {
return second;
}