-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeInfo.java
More file actions
35 lines (30 loc) · 922 Bytes
/
TimeInfo.java
File metadata and controls
35 lines (30 loc) · 922 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
package com.github.ryan6073.Seriously;
import java.util.Objects;
public class TimeInfo implements Comparable<TimeInfo>{
public int year=0;
public int month=0;
public TimeInfo(int _year, int _month){year = _year; month = _month;}
@Override
public int compareTo(TimeInfo o){
if(this.year<o.year)
return -1;
else if(this.year>o.year)
return 1;
else if(this.month<o.month)
return -1;
else if(this.month>o.month)
return 1;
else return 0;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
TimeInfo timeInfo = (TimeInfo) obj;
return year == timeInfo.year && month == timeInfo.month;
}
@Override
public int hashCode() {
return Objects.hash(year, month);
}
}