-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHMS.java
More file actions
45 lines (37 loc) · 933 Bytes
/
HMS.java
File metadata and controls
45 lines (37 loc) · 933 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
import java.util.Objects;
public class HMS implements Time {
private int hour;
private int minute;
private int second;
public HMS(int hour, int minute, int second) {
this.hour = hour;
this.minute = minute;
this.second = second;
}
public int getHours() {
return hour;
}
public int getMinutes() {
return minute;
}
public int getSeconds() {
return second;
}
@Override
public boolean equals(Object o) {
if (o instanceof Time) {
HMS time = (HMS) o;
return this.hour == time.hour
&& this.minute == time.minute
&& this.second == time.second;
} else {
return false;
}
}
public int hashCode() {
return Objects.hash(hour, minute, second);
}
public String toString() {
return hour + ":" + minute + ":" + second;
}
}