-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTime1.java
More file actions
119 lines (103 loc) · 2.84 KB
/
Copy pathTime1.java
File metadata and controls
119 lines (103 loc) · 2.84 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package MMN15;
/*
* Decompiled with CFR 0_110.
*/
public class Time1 {
private int _hour;
private int _minute;
private int _second;
private final int MIN_HOUR = 0;
private final int MIN_MINUTE = 0;
private final int MIN_SECOND = 0;
private final int MAX_HOUR = 23;
private final int MAX_MINUTE = 59;
private final int MAX_SECOND = 59;
private final int SEC_IN_HOUR = 3600;
private final int SEC_IN_MINUTE = 60;
public Time1(int h, int m, int s) {
this._hour = 0;
if (h >= 0 && h <= 23) {
this._hour = h;
}
this._minute = 0;
if (m >= 0 && m <= 59) {
this._minute = m;
}
this._second = 0;
if (s >= 0 && s <= 59) {
this._second = s;
}
}
public Time1(Time1 other) {
this._hour = other._hour;
this._minute = other._minute;
this._second = other._second;
}
public int getHour() {
return this._hour;
}
public int getMinute() {
return this._minute;
}
public int getSecond() {
return this._second;
}
public void setHour(int num) {
if (num >= 0 && num <= 23) {
this._hour = num;
}
}
public void setMinute(int num) {
if (num >= 0 && num <= 59) {
this._minute = num;
}
}
public void setSecond(int num) {
if (num >= 0 && num <= 59) {
this._second = num;
}
}
public long secFromMidnight() {
return this._hour * 3600 + this._minute * 60 + this._second;
}
public boolean equals(Time1 other) {
if (other != null && this._hour == other._hour && this._minute == other._minute && this._second == other._second) {
return true;
}
return false;
}
public boolean before(Time1 other) {
if (this._hour > other._hour) {
return false;
}
if (this._hour < other._hour) {
return true;
}
if (this._minute > other._minute) {
return false;
}
if (this._minute < other._minute) {
return true;
}
if (this._second > other._second) {
return false;
}
if (this._second < other._second) {
return true;
}
return false;
}
public boolean after(Time1 other) {
return other.before(this);
}
public int difference(Time1 other) {
return (int)(this.secFromMidnight() - other.secFromMidnight());
}
public String toString() {
String s = "";
s = this._hour < 10 ? s + "0" + this._hour + ":" : s + this._hour + ":";
s = this._minute < 10 ? s + "0" + this._minute + ":" : s + this._minute + ":";
s = this._second < 10 ? s + "0" + this._second : s + this._second;
return s;
}
}