forked from nus-cs2103-AY2122S2/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.java
79 lines (70 loc) · 1.84 KB
/
Task.java
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
package duke.task;
/**
* Represents a parent task for all child tasks.
* With its description, completion status and its type i.e. Todo, Deadline or Event.
*/
public class Task {
private final String description;
private boolean completed;
private final char type;
/**
* Creates a Task object.
*
* @param description description of the task.
* @param type type of the task.
*/
public Task(String description, char type) {
assert description != null : "Task[Task] description cannot be null.";
assert description.length() > 0 : "Task[Task] description must contain data.";
this.description = description;
this.completed = false;
this.type = type;
}
/**
* Gets description of task.
*
* @return Description of task.
*/
public String getDescription() {
return this.description;
}
/**
* Checks if task is completed.
*
* @return Task completed.
*/
public boolean getCompleted() {
return this.completed;
}
/**
* Gets the representation of whether task is completed.
*
* @return X marks task is completed.
*/
public String getStatusIcon() {
return (this.completed) ? "X" : " ";
}
/**
* Gets the type of task.
*
* @return Either Todo, Deadline or Event.
*/
public char getType() {
return this.type;
}
/**
* Updates that task is completed.
*
* @param setCompleted setCompleted is whether task is done.
*/
public void setCompleted(boolean setCompleted) {
this.completed = setCompleted;
}
/**
* Returns a formatted string of a general task.
*/
@Override
public String toString() {
return String.format("[%s] %s", this.getStatusIcon(), this.getDescription());
}
}