forked from nus-cs2103-AY2223S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.java
70 lines (62 loc) · 1.46 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
package duke;
/**
* Represents a task.
* <b>Note:</b> Every time a task is initialized, its isDone status will be set as false at first.
*
* @author Liu Han
*/
public class Task {
private String description;
protected boolean isDone;
/**
* Task Constructor
* @param description Description of the task.
*/
public Task(String description) {
this.description = description;
this.isDone = false;
}
/**
* Status Getter
* @return String that represents the status of the task ("X" or " " if it is done or not).
*/
public String getStatus() {
return (this.isDone ? "X" : " ");
}
public String getDescription() {
return this.description;
}
/**
* Status Setter
* <p>
* Set the status of the task as done
* </p>
*/
public void markAsDone() {
this.isDone = true;
}
/**
* Status Setter
* <p>
* Set the status of the task as not done
* </p>
*/
public void markAsNotDone() {
this.isDone = false;
}
/**
* Prints the task when list is called by the user
* @return String in the format <b>[isDone] description</b>.
*/
@Override
public String toString() {
return "[" + getStatus() + "] " + this.description;
}
/**
* A dummy function for subclasses to override
* @return Empty string.
*/
public String toSave() {
return "";
}
}