22
33import exceptions .NoDescriptionException ;
44
5+ import java .time .LocalDateTime ;
56import java .util .ArrayList ;
67import java .util .Arrays ;
78import java .time .format .DateTimeFormatter ;
1213 */
1314public abstract class Task {
1415 protected String description ;
15- private String taskTypeString ;
1616 protected boolean isDone ;
17+ private String taskTypeString ;
1718
18- private static final String DEFAULT_TASK_TYPE_STRING = "task" ;
1919 static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter .ofPattern ("yyyy-MM-dd HH:mm" );
2020
21+ private static final String DEFAULT_TASK_TYPE_STRING = "task" ;
22+ private static final boolean DEFAULT_TASK_IS_DONE = false ;
23+
2124 public Task () {
2225
2326 }
@@ -28,14 +31,7 @@ public Task() {
2831 * @throws NoDescriptionException If the description is empty.
2932 */
3033 public Task (String description ) throws NoDescriptionException {
31- this .taskTypeString = DEFAULT_TASK_TYPE_STRING ;
32- if ("" .equals (description )) {
33- throw new NoDescriptionException ("OOPS!!! The description of a "
34- + taskTypeString
35- + " cannot be empty.\n " );
36- }
37- this .description = description ;
38- this .isDone = false ;
34+ this (description , DEFAULT_TASK_TYPE_STRING , DEFAULT_TASK_IS_DONE );
3935 }
4036
4137 /**
@@ -45,14 +41,25 @@ public Task(String description) throws NoDescriptionException {
4541 * @throws NoDescriptionException If the description is empty.
4642 */
4743 public Task (String description , String taskTypeString ) throws NoDescriptionException {
44+ this (description , taskTypeString , DEFAULT_TASK_IS_DONE );
45+ }
46+
47+ /**
48+ * Constructs a {@code Task} with the input description, task type string, and task status.
49+ * @param description A not empty description.
50+ * @param taskTypeString A not empty task type string.
51+ * @param taskIsDone A boolean object indicating whether the task is done.
52+ * @throws NoDescriptionException If the description is empty.
53+ */
54+ public Task (String description , String taskTypeString , boolean taskIsDone ) throws NoDescriptionException {
4855 this .taskTypeString = taskTypeString ;
4956 if ("" .equals (description )) {
5057 throw new NoDescriptionException ("OOPS!!! The description of a "
5158 + this .taskTypeString
5259 + " cannot be empty.\n " );
5360 }
5461 this .description = description ;
55- this .isDone = false ;
62+ this .isDone = taskIsDone ;
5663 }
5764
5865 /**
0 commit comments