From f4cc88017664b5ecdb1eb4cd89358e98fc6ad3c7 Mon Sep 17 00:00:00 2001 From: Nereus Ng Wei Bin Date: Mon, 18 Sep 2023 01:38:59 +0800 Subject: [PATCH] Fix uninitialized field bug --- src/main/java/corgi/commands/AddTaskCommand.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/corgi/commands/AddTaskCommand.java b/src/main/java/corgi/commands/AddTaskCommand.java index 5c9e856eb7..dbc51686e4 100644 --- a/src/main/java/corgi/commands/AddTaskCommand.java +++ b/src/main/java/corgi/commands/AddTaskCommand.java @@ -3,8 +3,11 @@ import java.util.Stack; import corgi.State; +import corgi.tasks.Deadline; +import corgi.tasks.Event; import corgi.tasks.Task; import corgi.tasks.TaskList; +import corgi.tasks.ToDo; import corgi.ui.TextRenderer; import javafx.util.Pair; @@ -33,6 +36,13 @@ public class AddTaskCommand extends Command { public AddTaskCommand(Task target) { super(false); this.target = target; + if (target instanceof ToDo) { + this.taskType = "todo"; + } else if (target instanceof Deadline) { + this.taskType = "deadline"; + } else if (target instanceof Event) { + this.taskType = "event"; + } } /**