-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDates.java
More file actions
93 lines (76 loc) · 1.39 KB
/
Copy pathDates.java
File metadata and controls
93 lines (76 loc) · 1.39 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
public class Dates implements Comparable{
//Variables--------------------------------------------------------
private String task;
private int date;
//Methods----------------------------------------------------------
public int getDate()
{
return date;
}
public String getTask()
{
return new String(task);
}
public void setTask(String s)
{
this.task = s;
}
public String toString()
{
//Changed for readability in the export file
return (new StringBuffer("{Date: ").append(Integer.toString(date)).append("\t\tTask: ").append(task).append("}")).toString();
}
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if(o instanceof Dates)
{
Dates d = (Dates) o;
//compare
if(this.date == d.date && this.task.equals(d.task))
{
return true;
}
}
return false;
}
public Dates clone()
{
return new Dates(new String(task), date);
}
public int compareTo(Object o)
{
if(this == o)
{
return 0;
}
if(o instanceof Dates)
{
Dates d = (Dates) o;
return this.date - d.date;
}
else
{
throw new ClassCastException();
}
}
//Constructors--------------------------------------------------------
public Dates()
{
task = "";
date = 0;
}
public Dates(String t, int d)
{
task = t;
date = d;
}
public Dates(String t, int y, int m, int d)
{
task = t;
date = d + m*100 + y*10000;
}
}