-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDate.java
More file actions
30 lines (25 loc) · 698 Bytes
/
Copy pathDate.java
File metadata and controls
30 lines (25 loc) · 698 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
public class Date implements Comparable<Data> {
private final int day;
private final int month;
private final int year;
public Date( int d, int m, int y ) {
day = d;
month = m;
year = y;
}
public int day() { return day; }
public int month() { return month; }
public int year() { return year; }
public int compareTo( Data that ) {
if ( this.year > that.year ) return +1;
if ( this.year < that.year ) return -1;
if ( this.month > that.month ) return +1;
if ( this.month < that.month ) return -1;
if ( this.day > that.day ) return +1;
if ( this.day < that.day ) return -1;
return 0;
}
public String toString() {
return month + "/" + day + "/" + year;
}
}