Skip to content

Commit

Permalink
Call save function when removing the chatbot and remove writing to th…
Browse files Browse the repository at this point in the history
…e txt file after every action
  • Loading branch information
farissirraj committed Sep 20, 2023
1 parent 1eb5452 commit a3c8dc4
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void exitChatbot() throws IOException {
printLine();
System.out.println(" Bye. Hope to see you again soon!");
printLine();
this.writer.save(taskList);
this.writer.closeFile();
}

Expand Down Expand Up @@ -102,7 +103,6 @@ public void addTasks(String[] userInput){
Task todo = new ToDo(todoDescription);
taskList.add(todo);
addTaskCallback(todo);
this.writer.write(todo.taskFormatted());
break;
case "deadline":
int byIndex = Arrays.asList(userInput).indexOf("/by");
Expand All @@ -111,7 +111,6 @@ public void addTasks(String[] userInput){
Deadline deadline = new Deadline(deadlineDescription, deadlineTime);
taskList.add(deadline);
addTaskCallback(deadline);
this.writer.write(deadline.taskFormatted());
break;
case "event":
int fromIndex = Arrays.asList(userInput).indexOf("/from");
Expand All @@ -122,7 +121,6 @@ public void addTasks(String[] userInput){
Task event = new Event(eventDescription, from, to);
taskList.add(event);
addTaskCallback(event);
this.writer.write(event.taskFormatted());
break;
default:
}
Expand Down

0 comments on commit a3c8dc4

Please sign in to comment.