forked from nus-cs2103-AY2223S2/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask.java
88 lines (76 loc) · 1.88 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
80
81
82
83
84
85
86
87
88
package duke.tasks;
public class Task {
protected String description;
protected boolean isDone;
/**
* The building block for the 3 other tasks: Deadline, ToDos and Event.
*
* @param description description of the user's task.
*/
public Task(String description) {
this.description = description;
this.isDone = false;
}
/**
* Completion Status of the task.
*
* @return a String that indicates whether the task is done.
*/
public String getStatusIcon() {
return (isDone ? "[X]" : "[ ]");
}
/**
* Description of the task.
*
* @return a String that details the task
*/
public String getDescription() {
return this.description;
}
/**
* Check if the task is null
*
* @return boolean to check if its a null task
*/
public boolean emptyTask() {
if (description.equals("")) {
return true;
} else return false;
}
/**
* Mark the task as Done.
*/
public void mark() {
this.isDone = true;
}
/**
* Unmark the task, indicating it is not done.
*/
public void unmark() {
this.isDone = false;
}
public boolean containsKeyWord(String keyWord) {
return this.getDescription().contains(keyWord);
}
/**
* Status of its completion status
*
* @return Status of its completion status but in binary format for saving in Storage
*/
public String saveString() {
if (isDone) {
return "1";
} else {
return "0";
}
}
/**
* All the Information of the task
*
* @return a String of all the information of the task to be printed by the Ui
*/
@Override
public String toString() {
return String.format("%s %s", this.getStatusIcon(), this.getDescription());
}
}