-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTask.java
More file actions
114 lines (94 loc) · 2.8 KB
/
Task.java
File metadata and controls
114 lines (94 loc) · 2.8 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
import java.io.Serializable;
import java.util.*;
public class Task implements Serializable{
private String name=null;
private String priority;
private scheduledPriority[] scheduledPriorities = new scheduledPriority[3];
private ArrayList<Event> eventList = new ArrayList<Event>();
private String comment="Enter a comment";
private boolean complete;
Task(String toBeName) {
name = toBeName;
priority = "urgent";
complete = false;
scheduledPriority urgent=new scheduledPriority("urgent");
scheduledPriority current=new scheduledPriority("current");
scheduledPriority eventual=new scheduledPriority("eventual");
scheduledPriorities[0]=urgent;
scheduledPriorities[1]=current;
scheduledPriorities[2]=eventual;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPriorityLevel() {
//returns priority level
return priority;
}
public void setPriorityLevel(String priority) {
//changes the priority level
addEventToHistory(new priorityEvent(this.priority,priority));
this.priority = priority;
}
public scheduledPriority[] getScheduledPriorities() {
return scheduledPriorities;
}
public scheduledPriority getScheduledPriority(int level) {
return scheduledPriorities[level];
}
public void updateScheduledPriorities(scheduledPriority[] scheduledPriorities) {
this.scheduledPriorities = scheduledPriorities;
}
public void updatePriorityDate(Date date, int level) {
scheduledPriorities[level].setDate(date);
}
public String getDateString() {
String ds=null;
Loop: for (int i = scheduledPriorities.length - 1; i >= 0; i--) {
if (scheduledPriorities[i].getActive()) {
ds=Event.getDateString(scheduledPriorities[i].getDate());
break Loop;
}
}
return ds;
}
public ArrayList<Event> getEvents() {
//returns the event list of the task
return eventList;
}
public void addEventToHistory(Event event) {
//adds an event to the event list
eventList.add(event);
}
public String getComment() {
//returns a specific comment
return comment;
}
public void setComment(String newComment) {
//changes a specific comment
Event event=new commentEvent(comment,newComment);
addEventToHistory(event);
comment=newComment;
}
public void removeComment(int index) {
//removes a specific comment
Event event=new commentEvent(comment,0);
addEventToHistory(event);
comment="new comment";
}
public void edit() {
//opens the edit action page
EditAction edit=new EditAction(this);
edit.createAndShowGUI();
}
public boolean getComplete() {
//returns the completion status of a task
return complete;
}
public void setComplete(boolean newComplete) {
complete=newComplete;
}
}