From fab2cac643e5af6c19102751fc7e27b6ad1c901b Mon Sep 17 00:00:00 2001 From: xingyuan Date: Thu, 30 Sep 2021 22:19:10 +0800 Subject: [PATCH] docs changes --- src/main/java/Deadline.java | 8 ++++++++ src/main/java/Event.java | 8 ++++++++ src/main/java/Storage.java | 9 ++++++--- src/main/java/ToDo.java | 11 +++++++++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/main/java/Deadline.java b/src/main/java/Deadline.java index 37edbca06..94220487a 100644 --- a/src/main/java/Deadline.java +++ b/src/main/java/Deadline.java @@ -6,6 +6,14 @@ public Deadline(String description, String by) { this.by = by; } + public Deadline(String description, String by, String isDone) { + super(description); + this.by = by; + if (isDone.equals("1")) { + this.isDone = true; + } + } + @Override public void printTask() { System.out.println("[D]" + super.getStatusIcon() + super.getDescription() + "(by:" + by + ")"); diff --git a/src/main/java/Event.java b/src/main/java/Event.java index 8e1b9ff9f..e4fbb8482 100644 --- a/src/main/java/Event.java +++ b/src/main/java/Event.java @@ -6,6 +6,14 @@ public Event(String description, String at) { this.at = at; } + public Event(String description, String at, String isDone) { + super(description); + this.at = at; + if (isDone.equals("1")) { + this.isDone = true; + } + } + @Override public void printTask() { System.out.println("[E]" + super.getStatusIcon() + super.getDescription() + "(at: " + at + ")"); diff --git a/src/main/java/Storage.java b/src/main/java/Storage.java index e530c4a9c..9ccd34c19 100644 --- a/src/main/java/Storage.java +++ b/src/main/java/Storage.java @@ -39,19 +39,22 @@ public static void loadDukeTextFile(File dukeTextFile, TaskList list) { if (taskLetter.equals("T")) { String[] dukeLineSplit = dukeTextLine.split("\\|", 3); String todoDescription = dukeLineSplit[2]; - Task task = new ToDo(todoDescription); + String todoIsDone = dukeLineSplit[1]; + Task task = new ToDo(todoDescription, todoIsDone); list.addTaskList(task); } else if (taskLetter.equals("D")) {//Deadline String[] dukeLineSplit = dukeTextLine.split("\\|", 4); String deadlineDescription = dukeLineSplit[2].trim(); + String deadlineIsDone = dukeLineSplit[1]; String deadlineBy = dukeLineSplit[3].trim(); - Task task = new Deadline(deadlineDescription, deadlineBy); + Task task = new Deadline(deadlineDescription, deadlineBy, deadlineIsDone); list.addTaskList(task); } else { String[] dukeLineSplit = dukeTextLine.split("\\|", 4); String eventDescription = dukeLineSplit[2].trim(); String eventAt = dukeLineSplit[3].trim(); - Task task = new Event(eventDescription, eventAt); + String eventIsDone = dukeLineSplit[1]; + Task task = new Event(eventDescription, eventAt, eventIsDone); list.addTaskList(task); } } diff --git a/src/main/java/ToDo.java b/src/main/java/ToDo.java index e51727c5f..3f245d6fb 100644 --- a/src/main/java/ToDo.java +++ b/src/main/java/ToDo.java @@ -3,14 +3,21 @@ public ToDo(String description) { super(description); } + public ToDo(String description, String isDone) { + super(description); + if (isDone.equals("1")) { + this.isDone = true; + } + } + @Override public void printTask() { - System.out.println("[T]" + super.getStatusIcon() + super.getDescription() ); + System.out.println("[T]" + super.getStatusIcon() + super.getDescription()); } @Override public String getTextString() { - return("T" + "|" + super.getStatusValue() + "|" + super.getDescription() + "\n"); + return ("T" + "|" + super.getStatusValue() + "|" + super.getDescription() + "\n"); } }