diff --git a/.gitignore b/.gitignore
index f69985ef1f..76264e19cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ bin/
/text-ui-test/ACTUAL.txt
text-ui-test/EXPECTED-UNIX.TXT
+data/
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..97491e49f5
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,61 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'checkstyle'
+ id 'com.github.johnrengelman.shadow' version '5.1.0'
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
+ testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'
+
+ String javaFxVersion = '11'
+
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
+}
+
+test {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed"
+
+ showExceptions true
+ exceptionFormat "full"
+ showCauses true
+ showStackTraces true
+ showStandardStreams = false
+ }
+}
+
+application {
+ mainClassName = "pac.Launcher"
+}
+
+shadowJar {
+ archiveBaseName = "pac"
+ archiveClassifier = null
+}
+
+checkstyle {
+ toolVersion = '8.29'
+}
+
+run{
+ standardInput = System.in
+}
diff --git a/docs/README.md b/docs/README.md
index 8077118ebe..0fc2d88984 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,29 +1,75 @@
# User Guide
+___
-## Features
+## Features
-### Feature-ABC
+**Notes about the command format:**
+* Words in `UPPER_CASE` are the parameters to be supplied by the user.
+e.g. In `todo TASK_DESCRIPTION`, `TASK_DESCRIPTION` is a parameter which can be used as `todo buy groceries`.
-Description of the feature.
+* Parameters cannot be in any order.
+ e.g. `reschedule 1 /r 2022-10-25` is accepted but `reschedule /r 2022-10-25 1` is invaild command format.
-### Feature-XYZ
+* Extraneous parameters for commands that do not take in parameters will be ignored.
+e.g. `list XYZ` will be interpreted as `list`.
+
+___
+### Add a ToDo task : `todo`
-Description of the feature.
+Adds a ToDo task to the list with the given task description.
+**Format:** `todo TASK_DESCRIPTION`
+**e.g.** `todo buy groceries`
+___
+### Add an Event task : `event`
-## Usage
+Adds an Event task to the list with the given task description and date.
+**Format:** `event TASK_DESCRIPTION /at DATE`
+**e.g.** `event attend meeting /at 2022-02-15`
-### `Keyword` - Describe action
+* `DATE`should be in the format **YYYY-MM-DD** e.g. 2022-02-15
+___
+### Add a Deadline task : `deadline`
-Describe the action and its outcome.
+Adds an Deadline task to the list with the given task description and date.
+**Format:** `deadline TASK_DESCRIPTION /by DATE`
+**e.g.** `deadline submit project report /by 2022-02-15`
-Example of usage:
+* `DATE`should be in the format **YYYY-MM-DD** e.g. 2022-02-15
+___
+### Display all the tasks : `list`
-`keyword (optional arguments)`
+Displays all the tasks in the tasks list.
+**Format:** `list`
+**e.g.** `list`
+___
+### Mark a task as done : `mark`
+Marks the task with the given task index as done.
+**Format:** `mark TASK_INDEX`
+**e.g.** `mark 2`
+___
+### Mark a task as not done : `unmark`
+Marks the task with the given task index as not done.
+**Format:** `unmark TASK_INDEX`
+**e.g.** `unmark 2`
+___
+### Delete a task : `delete`
+Deletes the task with the given task index.
+**Format:** `delete TASK_INDEX`
+**e.g.** `delete 2`
+___
+### Reschedule a task : `reschedule`
+Reschedule the date of a `event` task or a `deadline` task with the given task index and date.
+**Format** `reschedule TASK_INDEX /r DATE`
+**e.g.** `reschedule 2 /r 2022-02-18`
-Expected outcome:
+* `reschedule` cannot be called for a `todo` task
+* `DATE`should be in the format **YYYY-MM-DD** e.g. 2022-02-15
+___
+### Search the list of tasks : `find`
+
+Finds all the tasks containing the given keyword.
+**Format:** `find KEYWORD`
+**e.g.** `find XYZ`
+___
-Description of the outcome.
-```
-expected output
-```
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..32cdbf54e6
Binary files /dev/null and b/docs/Ui.png differ
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..f3d88b1c2f
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..b7c8c5dbf5
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000000..2fe81a7d95
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000000..62bd9b9cce
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,103 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java
deleted file mode 100644
index 5d313334cc..0000000000
--- a/src/main/java/Duke.java
+++ /dev/null
@@ -1,10 +0,0 @@
-public class Duke {
- public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
- }
-}
diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..dc01367aac
--- /dev/null
+++ b/src/main/java/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: pac.Pac
+
diff --git a/src/main/java/pac/DialogBox.java b/src/main/java/pac/DialogBox.java
new file mode 100644
index 0000000000..bf53c1008f
--- /dev/null
+++ b/src/main/java/pac/DialogBox.java
@@ -0,0 +1,61 @@
+package pac;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.control.Label;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.HBox;
+
+/**
+ * An example of a custom control using FXML.
+ * This control represents a dialog box consisting of an ImageView to represent the speaker's face and a label
+ * containing text from the speaker.
+ */
+public class DialogBox extends HBox {
+ @FXML
+ private Label dialog;
+ @FXML
+ private ImageView displayPicture;
+
+ private DialogBox(String text, Image img) {
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
+ fxmlLoader.setController(this);
+ fxmlLoader.setRoot(this);
+ fxmlLoader.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ dialog.setText(text);
+ displayPicture.setImage(img);
+ }
+
+ /**
+ * Flips the dialog box such that the ImageView is on the left and text on the right.
+ */
+ private void flip() {
+ ObservableList tmp = FXCollections.observableArrayList(this.getChildren());
+ Collections.reverse(tmp);
+ getChildren().setAll(tmp);
+ setAlignment(Pos.TOP_LEFT);
+ }
+
+ public static DialogBox getUserDialog(String text, Image img) {
+ return new DialogBox(text, img);
+ }
+
+ public static DialogBox getDukeDialog(String text, Image img) {
+ var db = new DialogBox(text, img);
+ db.flip();
+ return db;
+ }
+}
diff --git a/src/main/java/pac/Launcher.java b/src/main/java/pac/Launcher.java
new file mode 100644
index 0000000000..7b2e4dfbdb
--- /dev/null
+++ b/src/main/java/pac/Launcher.java
@@ -0,0 +1,12 @@
+package pac;
+
+import javafx.application.Application;
+
+/**
+ * launches App
+ */
+public class Launcher {
+ public static void main(String[] args) {
+ Application.launch(Main.class, args);
+ }
+}
diff --git a/src/main/java/pac/Main.java b/src/main/java/pac/Main.java
new file mode 100644
index 0000000000..12ff2ec823
--- /dev/null
+++ b/src/main/java/pac/Main.java
@@ -0,0 +1,32 @@
+package pac;
+
+import java.io.IOException;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+
+/**
+ * A GUI for Pac using FXML.
+ */
+public class Main extends Application {
+
+ private Pac pac = new Pac("data/pac.txt");
+
+ @Override
+ public void start(Stage stage) {
+ try {
+ stage.setTitle("Pac");
+ FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
+ AnchorPane ap = fxmlLoader.load();
+ Scene scene = new Scene(ap);
+ stage.setScene(scene);
+ fxmlLoader.getController().setPac(pac);
+ stage.show();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/pac/MainWindow.java b/src/main/java/pac/MainWindow.java
new file mode 100644
index 0000000000..6828067a57
--- /dev/null
+++ b/src/main/java/pac/MainWindow.java
@@ -0,0 +1,51 @@
+package pac;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.ScrollPane;
+import javafx.scene.control.TextField;
+import javafx.scene.image.Image;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.VBox;
+/**
+ * Controller for MainWindow. Provides the layout for the other controls.
+ */
+public class MainWindow extends AnchorPane {
+ @FXML
+ private ScrollPane scrollPane;
+ @FXML
+ private VBox dialogContainer;
+ @FXML
+ private TextField userInput;
+ @FXML
+ private Button sendButton;
+
+ private Pac pac;
+
+ private Image userImage = new Image(this.getClass().getResourceAsStream("/images/User.png"));
+ private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/Pac.png"));
+
+ @FXML
+ public void initialize() {
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ }
+
+ public void setPac(Pac pac) {
+ this.pac = pac;
+ }
+
+ /**
+ * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to
+ * the dialog container. Clears the user input after processing.
+ */
+ @FXML
+ private void handleUserInput() {
+ String input = userInput.getText();
+ String response = pac.getResponse(input);
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, userImage),
+ DialogBox.getDukeDialog(response, dukeImage)
+ );
+ userInput.clear();
+ }
+}
diff --git a/src/main/java/pac/Pac.java b/src/main/java/pac/Pac.java
new file mode 100644
index 0000000000..1d27544eb4
--- /dev/null
+++ b/src/main/java/pac/Pac.java
@@ -0,0 +1,43 @@
+package pac;
+
+import pac.command.Command;
+import pac.parser.Parser;
+import pac.storage.Storage;
+import pac.task.TaskList;
+import pac.ui.Ui;
+
+import java.io.IOException;
+
+public class Pac {
+ private Storage storage;
+ private TaskList tasks;
+ private Ui ui;
+
+ public Pac(String filePath) {
+ ui = new Ui();
+ try {
+ storage = new Storage(filePath);
+ tasks = new TaskList(storage.readTasks());
+ } catch (IOException e) {
+ ui.showLoadingError();
+ } catch (PacException e) {
+ ui.showPacError(e);
+ tasks = new TaskList();
+ }
+ }
+
+ public String getResponse(String input) {
+ try {
+ Command command = Parser.parse(input);
+ return command.execute(tasks, ui, storage);
+ } catch (PacException e) {
+ return ui.showPacError(e);
+ } catch (IOException e) {
+ return ui.showIOError(e);
+ } catch (NumberFormatException e) {
+ return ui.showFormatError();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return ui.showFormatError();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/pac/PacException.java b/src/main/java/pac/PacException.java
new file mode 100644
index 0000000000..f4ae88752a
--- /dev/null
+++ b/src/main/java/pac/PacException.java
@@ -0,0 +1,20 @@
+package pac;
+
+/**
+ * PacException class to handle exceptions
+ */
+public class PacException extends Exception{
+
+ /**
+ * PacException constructor tskes in String
+ * @param message
+ */
+ public PacException(String message) {
+ super(message);
+ }
+
+ @Override
+ public String getMessage() {
+ return super.getMessage();
+ }
+}
diff --git a/src/main/java/pac/command/AddCommand.java b/src/main/java/pac/command/AddCommand.java
new file mode 100644
index 0000000000..15f13bd674
--- /dev/null
+++ b/src/main/java/pac/command/AddCommand.java
@@ -0,0 +1,38 @@
+package pac.command;
+
+import pac.task.Task;
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+import java.io.IOException;
+
+/**
+ * Executes the add command for tasks
+ * returns the ui message for Pac response
+ */
+public class AddCommand extends Command {
+ private final Task task;
+
+ /**
+ * AddCommand constructor takes in a task
+ * @param task
+ */
+ public AddCommand(Task task) {
+ this.task = task;
+ }
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ * @throws IOException
+ */
+ public String execute(TaskList tasks, Ui ui, Storage storage) throws IOException {
+ tasks.add(task);
+ storage.writeTasks(tasks);
+ return ui.showAddTask(task, tasks);
+ }
+}
diff --git a/src/main/java/pac/command/Command.java b/src/main/java/pac/command/Command.java
new file mode 100644
index 0000000000..a5397c0348
--- /dev/null
+++ b/src/main/java/pac/command/Command.java
@@ -0,0 +1,31 @@
+package pac.command;
+
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+import java.io.IOException;
+
+/**
+ * Abstract class Command
+ */
+public abstract class Command {
+
+ /**
+ * Executes command
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ * @throws IOException
+ */
+ public abstract String execute(TaskList tasks, Ui ui, Storage storage) throws IOException;
+
+ /**
+ *
+ * @return boolean value that indicates the program to exit
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
diff --git a/src/main/java/pac/command/DeleteCommand.java b/src/main/java/pac/command/DeleteCommand.java
new file mode 100644
index 0000000000..eea2979c63
--- /dev/null
+++ b/src/main/java/pac/command/DeleteCommand.java
@@ -0,0 +1,42 @@
+package pac.command;
+
+import pac.task.Task;
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+import java.io.IOException;
+
+/**
+ * executes the delete command for tasks.
+ * returns the ui message for Pac response
+ */
+public class DeleteCommand extends Command {
+
+ private final int taskIndex;
+
+ /**
+ * DeleteCommand constructor takes in taskIndex
+ * @param taskIndex
+ */
+ public DeleteCommand(int taskIndex) {
+ this.taskIndex = taskIndex;
+ }
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ * @throws IOException
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) throws IOException {
+ Task task = tasks.get(taskIndex);
+ tasks.delete(taskIndex);
+ int size = tasks.getSize();
+ storage.writeTasks(tasks);
+ return ui.showDelete(task, tasks, size);
+ }
+}
diff --git a/src/main/java/pac/command/ExitCommand.java b/src/main/java/pac/command/ExitCommand.java
new file mode 100644
index 0000000000..c27a3f12e0
--- /dev/null
+++ b/src/main/java/pac/command/ExitCommand.java
@@ -0,0 +1,33 @@
+package pac.command;
+
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+/**
+ * Executes the exit command for tasks
+ * returns the ui message for Pac response
+ */
+public class ExitCommand extends Command {
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) {
+ return ui.showExit();
+ }
+
+ /**
+ * Changes isExit() to true
+ * @return returns boolean value that indicates the program to exit
+ */
+ @Override
+ public boolean isExit() {
+ return true;
+ }
+}
diff --git a/src/main/java/pac/command/FindCommand.java b/src/main/java/pac/command/FindCommand.java
new file mode 100644
index 0000000000..4edd26e69b
--- /dev/null
+++ b/src/main/java/pac/command/FindCommand.java
@@ -0,0 +1,37 @@
+package pac.command;
+
+import pac.storage.Storage;
+import pac.task.TaskList;
+import pac.ui.Ui;
+
+import java.io.IOException;
+
+/**
+ * Executes the find command for tasks
+ * returns the ui message for Pac response
+ */
+public class FindCommand extends Command{
+ private final String keyword;
+
+ /**
+ * Find Command constructor takes in a String
+ * @param keyword
+ */
+ public FindCommand(String keyword) {
+ this.keyword = keyword;
+ }
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ * @throws IOException
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) throws IOException {
+ TaskList matchingTasks = tasks.find(keyword);
+ return ui.showFind(matchingTasks);
+ }
+}
diff --git a/src/main/java/pac/command/ListCommand.java b/src/main/java/pac/command/ListCommand.java
new file mode 100644
index 0000000000..3534e8700a
--- /dev/null
+++ b/src/main/java/pac/command/ListCommand.java
@@ -0,0 +1,24 @@
+package pac.command;
+
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+/**
+* Executes the exit command for tasks
+ * returns the ui message for Pac response
+ */
+public class ListCommand extends Command{
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) {
+ return ui.showList(tasks);
+ }
+}
diff --git a/src/main/java/pac/command/MarkCommand.java b/src/main/java/pac/command/MarkCommand.java
new file mode 100644
index 0000000000..cf6be5f087
--- /dev/null
+++ b/src/main/java/pac/command/MarkCommand.java
@@ -0,0 +1,45 @@
+package pac.command;
+
+import pac.PacException;
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+import java.io.IOException;
+
+/**
+ * Executes the mark command for tasks
+ * returns the ui message for Pac response
+ */
+public class MarkCommand extends Command{
+
+ private final int taskIndex;
+
+ /**
+ * MarkCommand constructor takes in a int
+ * @param taskIndex
+ */
+ public MarkCommand(int taskIndex) {
+ this.taskIndex = taskIndex;
+ }
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ * @throws IOException
+ * @throws IndexOutOfBoundsException
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) throws IOException, IndexOutOfBoundsException {
+ try {
+ tasks.mark(taskIndex);
+ storage.writeTasks(tasks);
+ return ui.showMark(tasks.get(taskIndex));
+ } catch (IndexOutOfBoundsException e) {
+ return ui.showIndexOutOfBoundsError(e);
+ }
+ }
+}
diff --git a/src/main/java/pac/command/RescheduleCommand.java b/src/main/java/pac/command/RescheduleCommand.java
new file mode 100644
index 0000000000..9c21b27a68
--- /dev/null
+++ b/src/main/java/pac/command/RescheduleCommand.java
@@ -0,0 +1,49 @@
+package pac.command;
+
+import pac.PacException;
+import pac.storage.Storage;
+import pac.task.Task;
+import pac.task.TaskList;
+import pac.ui.Ui;
+
+import java.io.IOException;
+
+/**
+ * Executes the reschedule command for tasks
+ * returns the ui message for Pac response
+ */
+public class RescheduleCommand extends Command{
+ private final int taskIndex;
+ private final String dateTimeStr;
+
+ /**
+ * RescheduleCommand constructor takes in a int and String
+ * @param taskIndex
+ * @param dateTimeStr
+ */
+ public RescheduleCommand(int taskIndex, String dateTimeStr) {
+ this.taskIndex = taskIndex;
+ this.dateTimeStr = dateTimeStr;
+ }
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) {
+ try {
+ tasks.get(taskIndex).rescheduleDate(dateTimeStr);
+ storage.writeTasks(tasks);
+ Task task = tasks.get(taskIndex);
+ return ui.showReschedule(task);
+ } catch (PacException e) {
+ return ui.showPacError(e);
+ } catch (IOException e) {
+ return ui.showIOError(e);
+ }
+ }
+}
diff --git a/src/main/java/pac/command/UnmarkCommand.java b/src/main/java/pac/command/UnmarkCommand.java
new file mode 100644
index 0000000000..30b2fdafae
--- /dev/null
+++ b/src/main/java/pac/command/UnmarkCommand.java
@@ -0,0 +1,44 @@
+package pac.command;
+
+import pac.PacException;
+import pac.task.TaskList;
+import pac.ui.Ui;
+import pac.storage.Storage;
+
+import java.io.IOException;
+
+/**
+ * Executes the exit command for tasks
+ * returns the ui message for Pac response
+ */
+public class UnmarkCommand extends Command {
+ private final int taskIndex;
+
+ /**
+ * UnmarkCommand constructor takes in int
+ * @param taskIndex
+ */
+ public UnmarkCommand(int taskIndex) {
+ this.taskIndex = taskIndex;
+ }
+
+ /**
+ *
+ * @param tasks
+ * @param ui
+ * @param storage
+ * @return
+ * @throws IOException
+ */
+ @Override
+ public String execute(TaskList tasks, Ui ui, Storage storage) throws IOException {
+ try {
+ tasks.unmark(taskIndex);
+ storage.writeTasks(tasks);
+ return ui.showUnmark(tasks.get(taskIndex));
+ } catch (IndexOutOfBoundsException e) {
+ return ui.showIndexOutOfBoundsError(e);
+ }
+
+ }
+}
diff --git a/src/main/java/pac/parser/Commands.java b/src/main/java/pac/parser/Commands.java
new file mode 100644
index 0000000000..01ea85d22d
--- /dev/null
+++ b/src/main/java/pac/parser/Commands.java
@@ -0,0 +1,17 @@
+package pac.parser;
+
+/**
+ * All the commands Pac recognises
+ */
+public enum Commands {
+ LIST,
+ MARK,
+ UNMARK,
+ TODO,
+ DEADLINE,
+ EVENT,
+ DELETE,
+ FIND,
+ RESCHEDULE,
+ BYE,
+}
\ No newline at end of file
diff --git a/src/main/java/pac/parser/Parser.java b/src/main/java/pac/parser/Parser.java
new file mode 100644
index 0000000000..d1f807e572
--- /dev/null
+++ b/src/main/java/pac/parser/Parser.java
@@ -0,0 +1,99 @@
+package pac.parser;
+
+import pac.command.AddCommand;
+import pac.command.Command;
+import pac.command.FindCommand;
+import pac.command.RescheduleCommand;
+import pac.task.Deadline;
+import pac.command.DeleteCommand;
+import pac.task.Event;
+import pac.command.ExitCommand;
+import pac.command.ListCommand;
+import pac.command.MarkCommand;
+import pac.PacException;
+import pac.task.ToDo;
+import pac.command.UnmarkCommand;
+
+/**
+ * Parser parses the user input and returns a Command
+ */
+public class Parser {
+
+ /**
+ * parses the user input and returns the corresponding command
+ * @param fullCommand
+ * @return
+ * @throws PacException
+ */
+ public static Command parse(String fullCommand) throws PacException {
+ String[] commandArray = fullCommand.split(" ", 2);
+ String keyWord = commandArray[0].toLowerCase();
+ Commands command;
+
+ switch (keyWord) {
+ case "bye":
+ command = Commands.BYE;
+ break;
+ case "list":
+ command = Commands.LIST;
+ break;
+ case "mark":
+ command = Commands.MARK;
+ break;
+ case "unmark":
+ command = Commands.UNMARK;
+ break;
+ case "todo":
+ command = Commands.TODO;
+ break;
+ case "deadline":
+ command = Commands.DEADLINE;
+ break;
+ case "event":
+ command = Commands.EVENT;
+ break;
+ case "delete":
+ command = Commands.DELETE;
+ break;
+ case "find":
+ command = Commands.FIND;
+ break;
+ case "reschedule":
+ command = Commands.RESCHEDULE;
+ break;
+ default:
+ throw new PacException("Invalid Command.");
+ }
+
+ switch (command) {
+ case BYE:
+ return new ExitCommand();
+ case LIST:
+ return new ListCommand();
+ case MARK:
+ return new MarkCommand(Integer.parseInt(commandArray[1]) - 1);
+ case UNMARK:
+ return new UnmarkCommand(Integer.parseInt(commandArray[1]) - 1);
+ case TODO:
+ if(commandArray[1].trim().length() == 0) {
+ throw new PacException("Invalid Command Format");
+ }
+ return new AddCommand(new ToDo(commandArray[1]));
+ case DEADLINE:
+ String[] deadlineArray = commandArray[1].split(" /by ", 2);
+ return new AddCommand(new Deadline(deadlineArray[0], deadlineArray[1]));
+ case EVENT:
+ String[] eventArray = commandArray[1].split(" /at ", 2);
+ return new AddCommand(new Event(eventArray[0], eventArray[1]));
+ case DELETE:
+ return new DeleteCommand(Integer.parseInt(commandArray[1]) - 1);
+ case FIND:
+ return new FindCommand(commandArray[1]);
+ case RESCHEDULE:
+ String[] rescheduleArray = commandArray[1].split(" /r ", 2);
+ return new RescheduleCommand(Integer.parseInt(rescheduleArray[0]) - 1, rescheduleArray[1]);
+ default:
+ throw new PacException("Invalid Command.");
+ }
+ }
+}
diff --git a/src/main/java/pac/storage/Storage.java b/src/main/java/pac/storage/Storage.java
new file mode 100644
index 0000000000..813f211c98
--- /dev/null
+++ b/src/main/java/pac/storage/Storage.java
@@ -0,0 +1,93 @@
+package pac.storage;
+
+import pac.task.Deadline;
+import pac.task.Event;
+import pac.PacException;
+import pac.task.Task;
+import pac.task.TaskList;
+import pac.task.ToDo;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+/**
+ * Responsible for storing the tasks in a data file
+ */
+public class Storage {
+
+ private final File file;
+
+ /**
+ * creates a data file at filePath is it not existing already
+ * @param filePath
+ * @throws IOException
+ * @throws PacException
+ */
+ public Storage(String filePath) throws IOException, PacException {
+
+ File folder = new File(filePath.split("/")[0]);
+ if (!folder.exists()) {
+ if(!folder.mkdir()) {
+ throw new PacException("Something went wrong while creating data file.");
+ }
+ }
+
+ File file = new File(filePath);
+ if (!file.exists()) {
+ if(!file.createNewFile()) {
+ throw new PacException("Something went wrong while creating data file.");
+ }
+ }
+
+ this.file = file;
+ }
+
+ /**
+ * writes the tasks to the data file
+ * @param tasks
+ * @throws IOException
+ */
+ public void writeTasks(TaskList tasks) throws IOException{
+ String textToWrite = "";
+ FileWriter fw = new FileWriter(file);
+ for (Task t : tasks.getTasks()) {
+ textToWrite = textToWrite + t.toWrite();
+ }
+ fw.write(textToWrite);
+ fw.close();
+ }
+
+ /**
+ * reads the data file and returns a ArrayList of tasks
+ * @return
+ * @throws FileNotFoundException
+ */
+ public ArrayList readTasks() throws FileNotFoundException {
+ ArrayList tasks = new ArrayList<>();
+ Scanner sc = new Scanner(file);
+ while (sc.hasNext()) {
+ String textToRead = sc.nextLine();
+ String[] textArray = textToRead.split("~");
+ switch (textArray[0]) {
+ case "T":
+ tasks.add(new ToDo(textArray[2], textArray[1].equals("1")));
+ break;
+ case "E":
+ tasks.add(new Event(textArray[2], textArray[3],
+ textArray[1].equals("1")));
+ break;
+ case "D":
+ tasks.add(new Deadline(textArray[2], textArray[3],
+ textArray[1].equals("1")));
+ break;
+ default:
+ break;
+ }
+ }
+ return tasks;
+ }
+}
diff --git a/src/main/java/pac/task/Deadline.java b/src/main/java/pac/task/Deadline.java
new file mode 100644
index 0000000000..98ddb9d271
--- /dev/null
+++ b/src/main/java/pac/task/Deadline.java
@@ -0,0 +1,61 @@
+package pac.task;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * For deadline tasks
+ */
+public class Deadline extends Task{
+ private LocalDate dateTime;
+ private String dateTimeStr;
+
+ LocalDate getDateTime() {
+ return dateTime;
+ }
+
+ public Deadline(String description, String dateTimeStr) {
+ super(description);
+ this.dateTimeStr = dateTimeStr;
+ this.dateTime = LocalDate.parse(dateTimeStr);
+ }
+
+ public Deadline(String description, String dateTimeStr, boolean isDone) {
+ super(description, isDone);
+ this.dateTimeStr = dateTimeStr;
+ this.dateTime = LocalDate.parse(dateTimeStr);
+ }
+
+ /**
+ * Reschedules the date
+ * @param dateTimeStr
+ */
+ @Override
+ public void rescheduleDate(String dateTimeStr) {
+ this.dateTimeStr = dateTimeStr;
+ this.dateTime = LocalDate.parse(dateTimeStr);
+ }
+
+ /**
+ * Returns the String that is written into data file
+ * @return
+ */
+ @Override
+ public String toWrite() {
+ int bool;
+
+ if(isDone) {
+ bool = 1;
+ } else {
+ bool = 0;
+ }
+
+ return "D~" + bool + "~" + getDescription() + "~" +
+ dateTimeStr + System.lineSeparator();
+ }
+
+ @Override
+ public String toString() {
+ return "[D]" + super.toString() + " (by: " + dateTime.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) + ")";
+ }
+}
diff --git a/src/main/java/pac/task/Event.java b/src/main/java/pac/task/Event.java
new file mode 100644
index 0000000000..c151743911
--- /dev/null
+++ b/src/main/java/pac/task/Event.java
@@ -0,0 +1,60 @@
+package pac.task;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * For event tasks
+ */
+public class Event extends Task {
+ private LocalDate dateTime;
+ private String dateTimeStr;
+
+ LocalDate getDateTime() {
+ return dateTime;
+ }
+
+ public Event(String description, String dateTimeStr) {
+ super(description);
+ this.dateTimeStr = dateTimeStr;
+ this.dateTime = LocalDate.parse(dateTimeStr);
+ }
+
+ public Event(String description, String dateTimeStr, boolean isDone) {
+ super(description, isDone);
+ this.dateTimeStr = dateTimeStr;
+ this.dateTime = LocalDate.parse(dateTimeStr);
+ }
+
+ /**
+ * Reschedules the date
+ * @param dateTimeStr
+ */
+ @Override
+ public void rescheduleDate(String dateTimeStr) {
+ this.dateTimeStr = dateTimeStr;
+ this.dateTime = LocalDate.parse(dateTimeStr);
+ }
+
+ /**
+ * Returns the String that is written into data file
+ * @return
+ */
+ @Override
+ public String toWrite() {
+ int bool;
+ if(isDone) {
+ bool = 1;
+ } else {
+ bool = 0;
+ }
+
+ return "E~" + bool + "~" + getDescription() + "~" +
+ dateTimeStr + System.lineSeparator();
+ }
+
+ @Override
+ public String toString() {
+ return "[E]" + super.toString() + " (at: " + dateTime.format(DateTimeFormatter.ofPattern("MMM dd yyyy")) + ")";
+ }
+}
diff --git a/src/main/java/pac/task/Task.java b/src/main/java/pac/task/Task.java
new file mode 100644
index 0000000000..ecd55c6ec9
--- /dev/null
+++ b/src/main/java/pac/task/Task.java
@@ -0,0 +1,77 @@
+package pac.task;
+
+import pac.PacException;
+
+/**
+ * Abstract class Task
+ */
+public abstract class Task {
+ private final String description;
+ protected boolean isDone;
+
+ public Task(String description) {
+ this.description = description;
+ this.isDone = false;
+ }
+
+ public Task(String description, boolean isDone) {
+ this.description = description;
+ this.isDone = isDone;
+ }
+
+ /**
+ * marks isDone as true
+ * @return
+ */
+ Task markAsDone() {
+ this.isDone = true;
+ return this;
+ }
+
+ /**
+ * marks isDone as false
+ * @return
+ */
+ Task markAsNotDone() {
+ this.isDone = false;
+ return this;
+ }
+
+ /**
+ *
+ * @return task description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ *
+ * @return isDone
+ */
+ public boolean isMarked() {
+ return this.isDone;
+ }
+
+ /**
+ * abstract method for reschedule
+ * @param dateTimeStr
+ * @throws PacException
+ */
+ abstract public void rescheduleDate(String dateTimeStr) throws PacException;
+
+ /**
+ * abstract method for writing tasks to data file
+ * @return
+ */
+ abstract public String toWrite();
+
+ @Override
+ public String toString() {
+ if (this.isDone) {
+ return "[X] " + this.description;
+ } else {
+ return "[ ] " + this.description;
+ }
+ }
+}
diff --git a/src/main/java/pac/task/TaskList.java b/src/main/java/pac/task/TaskList.java
new file mode 100644
index 0000000000..726f7d63a1
--- /dev/null
+++ b/src/main/java/pac/task/TaskList.java
@@ -0,0 +1,65 @@
+package pac.task;
+
+import java.util.ArrayList;
+
+/**
+ * For the list of Tasks
+ */
+public class TaskList {
+ public ArrayList tasks;
+
+ public TaskList() {
+ this.tasks = new ArrayList<>();
+ }
+
+ public TaskList(ArrayList tasks) {
+ this.tasks = tasks;
+ }
+
+ public ArrayList getTasks() {
+ return this.tasks;
+ }
+
+ public Task get(int i) {
+ return this.tasks.get(i);
+ }
+
+ public int getSize() {
+ return this.tasks.size();
+ }
+
+ public boolean isEmpty() {
+ return this.tasks.isEmpty();
+ }
+
+ public void mark(int index) throws IndexOutOfBoundsException {
+ tasks.get(index).markAsDone();
+ }
+
+ public void unmark(int index) throws IndexOutOfBoundsException{
+ tasks.get(index).markAsNotDone();
+ }
+
+ /**
+ * returns new TaskList with list of tasks containing the keyword
+ * @param keyword
+ * @return
+ */
+ public TaskList find(String keyword) {
+ ArrayList matchingTasks = new ArrayList<>();
+ for (Task t : tasks) {
+ if(t.getDescription().contains(keyword)) {
+ matchingTasks.add(t);
+ }
+ }
+ return new TaskList(matchingTasks);
+ }
+
+ public void add(Task task) {
+ this.tasks.add(task);
+ }
+
+ public void delete(int index) {
+ tasks.remove(index);
+ }
+}
diff --git a/src/main/java/pac/task/ToDo.java b/src/main/java/pac/task/ToDo.java
new file mode 100644
index 0000000000..4db9262b6b
--- /dev/null
+++ b/src/main/java/pac/task/ToDo.java
@@ -0,0 +1,48 @@
+package pac.task;
+
+import pac.PacException;
+
+/**
+ * For todo tasks
+ */
+public class ToDo extends Task {
+ public ToDo(String description) {
+ super(description);
+ }
+
+ public ToDo(String description, boolean isDone) {
+ super(description, isDone);
+ }
+
+ /**
+ * Returns the String that is written into data file
+ * @return
+ */
+ @Override
+ public String toWrite() {
+ int bool;
+
+ if(isDone) {
+ bool = 1;
+ } else {
+ bool = 0;
+ }
+
+ return "T~" + bool + "~" + getDescription() + System.lineSeparator();
+ }
+
+ /**
+ * throws PacException
+ * @param datetimeStr
+ * @throws PacException
+ */
+ @Override
+ public void rescheduleDate(String datetimeStr) throws PacException{
+ throw new PacException("Cannot reschedule todo task.");
+ }
+
+ @Override
+ public String toString() {
+ return "[T]" + super.toString();
+ }
+}
diff --git a/src/main/java/pac/ui/Ui.java b/src/main/java/pac/ui/Ui.java
new file mode 100644
index 0000000000..2946f0affb
--- /dev/null
+++ b/src/main/java/pac/ui/Ui.java
@@ -0,0 +1,200 @@
+package pac.ui;
+
+import pac.PacException;
+import pac.task.Task;
+import pac.task.TaskList;
+
+import java.io.IOException;
+import java.util.Scanner;
+
+/**
+ * returns String for Pac response
+ */
+public class Ui {
+
+ /**
+ * ui response for exit command
+ * @return
+ */
+ public String showExit(){
+ return ("Goodbye! See you soon. :)");
+ }
+
+ /**
+ * ui response for list command
+ * @param tasks
+ * @return
+ */
+ public String showList(TaskList tasks){
+ int i = 1;
+ StringBuilder response = new StringBuilder();
+
+ if(tasks.isEmpty()) {
+ response.append("There are no tasks left to complete.")
+ .append(System.getProperty("line.separator"));
+ } else {
+ for (Task task : tasks.getTasks()) {
+ response.append(i).append(". ").append(task.toString())
+ .append(System.getProperty("line.separator"));
+ i += 1;
+ }
+ }
+
+ return response.toString();
+ }
+
+ /**
+ * ui response for find command
+ * @param matchingTasks
+ * @return
+ */
+ public String showFind(TaskList matchingTasks) {
+ int i = 1;
+ StringBuilder response = new StringBuilder();
+
+ if (matchingTasks.isEmpty()) {
+ response.append("here are no tasks containing the keyword.")
+ .append(System.getProperty("line.separator"));
+ } else {
+ for (Task task : matchingTasks.getTasks()) {
+ response.append(i).append(". ").append(task.toString())
+ .append(System.getProperty("line.separator"));
+ i += 1;
+ }
+ }
+
+ return response.toString();
+ }
+
+ /**
+ * ui response for mark command
+ * @param task
+ * @return
+ */
+ public String showMark(Task task) {
+ StringBuilder response = new StringBuilder();
+
+ if (task.isMarked()) {
+ response.append("Task is already marked as done.")
+ .append(System.getProperty("line.separator")).append(task.toString())
+ .append(System.getProperty("line.separator"));
+ } else {
+ response.append("Task is marked as done.")
+ .append(System.getProperty("line.separator")).append(task.toString())
+ .append(System.getProperty("line.separator"));
+ }
+
+ return response.toString();
+ }
+
+ /**
+ * ui response for unmark command
+ * @param task
+ * @return
+ */
+ public String showUnmark(Task task) {
+ StringBuilder response = new StringBuilder();
+
+ if (!task.isMarked()) {
+ response.append("Task is already marked as not done.")
+ .append(System.getProperty("line.separator")).append(task.toString())
+ .append(System.getProperty("line.separator"));
+ } else {
+ response.append("Task is marked as not done.")
+ .append(System.getProperty("line.separator")).append(task.toString())
+ .append(System.getProperty("line.separator"));
+ }
+
+ return response.toString();
+ }
+
+ /**
+ * ui response for add command
+ * @param task
+ * @param tasks
+ * @return
+ */
+ public String showAddTask(Task task, TaskList tasks) {
+ StringBuilder response = new StringBuilder();
+
+ response.append("added: ").append(task.toString())
+ .append(System.getProperty("line.separator")).append("You have ")
+ .append(tasks.getSize()).append(" tasks in your list.")
+ .append(System.getProperty("line.separator"));
+
+ return response.toString();
+ }
+
+ /**
+ * ui response for delete command
+ * @param task
+ * @param tasks
+ * @param size
+ * @return
+ */
+ public String showDelete(Task task, TaskList tasks, int size) {
+ StringBuilder response = new StringBuilder();
+ response.append("Task has been deleted: ").append(task.toString())
+ .append(System.getProperty("line.separator"))
+ .append("You have ").append(size).append(" tasks in your list")
+ .append(System.getProperty("line.separator"));
+ return response.toString();
+ }
+
+ /**
+ * ui response for reschedule command
+ * @param task
+ * @return
+ */
+ public String showReschedule(Task task) {
+ StringBuilder response = new StringBuilder();
+
+ response.append("rescheduled: ").append(task.toString())
+ .append(System.getProperty("line.separator"));
+
+ return response.toString();
+ }
+
+ /**
+ * ui response for loading error
+ * @return
+ */
+ public String showLoadingError() {
+ return "Something went wrong while reading the data file.";
+ }
+
+ /**
+ * ui response for pac exception
+ * @param e
+ * @return
+ */
+ public String showPacError(PacException e) {
+ return e.getMessage();
+ }
+
+ /**
+ * ui response for IOException
+ * @param e
+ * @return
+ */
+ public String showIOError(IOException e) {
+ return e.getMessage();
+ }
+
+ /**
+ * ui response for NumberFormatException
+ * @return
+ */
+ public String showFormatError() {
+ return "Invalid Command Format";
+ }
+
+ /**
+ * ui response for IndexOutOfBoundsException
+ * @param e
+ * @return
+ */
+ public String showIndexOutOfBoundsError(IndexOutOfBoundsException e) {
+ return "Sorry! Invalid Index.";
+ }
+}
diff --git a/src/main/resources/images/Pac.png b/src/main/resources/images/Pac.png
new file mode 100644
index 0000000000..d893658717
Binary files /dev/null and b/src/main/resources/images/Pac.png differ
diff --git a/src/main/resources/images/User.png b/src/main/resources/images/User.png
new file mode 100644
index 0000000000..3c82f45461
Binary files /dev/null and b/src/main/resources/images/User.png differ
diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml
new file mode 100644
index 0000000000..ca57907e3f
--- /dev/null
+++ b/src/main/resources/view/DialogBox.fxml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
new file mode 100644
index 0000000000..e3c5ad5536
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/pac/parser/ParserTest.java b/src/test/java/pac/parser/ParserTest.java
new file mode 100644
index 0000000000..108a725e7d
--- /dev/null
+++ b/src/test/java/pac/parser/ParserTest.java
@@ -0,0 +1,18 @@
+package pac.parser;
+
+import pac.PacException;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ParserTest {
+ @Test
+ public void parse_invalidCommand_exceptionThrown() {
+ try {
+ Parser.parse("todotask buy groceries");
+ } catch (PacException e) {
+ assertEquals("Sorry! Invalid Command.",e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/pac/task/DeadlineTest.java b/src/test/java/pac/task/DeadlineTest.java
new file mode 100644
index 0000000000..fb276a6060
--- /dev/null
+++ b/src/test/java/pac/task/DeadlineTest.java
@@ -0,0 +1,19 @@
+package pac.task;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class DeadlineTest {
+ @Test
+ public void toString_validInput_validString() {
+ assertEquals("[D][ ] get a haircut (by: Mar 15 2022)",
+ new Deadline("get a haircut", "2022-03-15").toString());
+ }
+
+ @Test
+ public void toWrite_validInput_validString() {
+ assertEquals("D~0~get a haircut~2022-03-15" + System.lineSeparator(),
+ new Deadline("get a haircut", "2022-03-15").toWrite());
+ }
+}
diff --git a/src/test/java/pac/task/EventTest.java b/src/test/java/pac/task/EventTest.java
new file mode 100644
index 0000000000..f2daa5c175
--- /dev/null
+++ b/src/test/java/pac/task/EventTest.java
@@ -0,0 +1,19 @@
+package pac.task;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class EventTest {
+ @Test
+ public void toString_validInput_validString() {
+ assertEquals("[E][ ] get a haircut (at: Mar 15 2022)",
+ new Event("get a haircut", "2022-03-15").toString());
+ }
+
+ @Test
+ public void toWrite_validInput_validString() {
+ assertEquals("E~1~get a haircut~2022-03-15" + System.lineSeparator(),
+ new Event("get a haircut", "2022-03-15").markAsDone().toWrite());
+ }
+}
diff --git a/src/test/java/pac/task/ToDoTest.java b/src/test/java/pac/task/ToDoTest.java
new file mode 100644
index 0000000000..c79302a21d
--- /dev/null
+++ b/src/test/java/pac/task/ToDoTest.java
@@ -0,0 +1,18 @@
+package pac.task;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ToDoTest {
+ @Test
+ public void toString_validInput_validString() {
+ assertEquals("[T][ ] get a haircut", new ToDo("get a haircut").toString());
+ }
+
+ @Test
+ public void toWrite_validInput_validString() {
+ assertEquals("T~1~get a haircut" + System.lineSeparator(),
+ new ToDo("get a haircut").markAsDone().toWrite());
+ }
+}
diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT
index 657e74f6e7..21794eeebb 100644
--- a/text-ui-test/EXPECTED.TXT
+++ b/text-ui-test/EXPECTED.TXT
@@ -1,7 +1,63 @@
-Hello from
- ____ _
-| _ \ _ _| | _____
-| | | | | | | |/ / _ \
-| |_| | |_| | < __/
-|____/ \__,_|_|\_\___|
+----------------------------------------------------
+----------------------------------------------------
+ ____ ___ _____
+| _ \ / _ \ | ___|
+| |_| | | |_| | | |
+| __/ | | | | | |___
+|_| |_| |_| |_____|
+
+Hello there! I'm Pac, your very own Personal Assistant ChatBot.
+How may I help you?
+----------------------------------------------------
+
+----------------------------------------------------
+added: [T][ ] get a haircut
+You have 1 tasks in your list
+----------------------------------------------------
+
+----------------------------------------------------
+added: [E][ ] attend meeting (at: 4pm 24th Jan)
+You have 2 tasks in your list
+----------------------------------------------------
+
+----------------------------------------------------
+1. [T][ ] get a haircut
+2. [E][ ] attend meeting (at: 4pm 24th Jan)
+----------------------------------------------------
+
+----------------------------------------------------
+added: [D][ ] submit project (by: 11 30pm 30th Jan)
+You have 3 tasks in your list
+----------------------------------------------------
+
+----------------------------------------------------
+Task is marked as done.
+[E][X] attend meeting (at: 4pm 24th Jan)
+----------------------------------------------------
+
+----------------------------------------------------
+1. [T][ ] get a haircut
+2. [E][X] attend meeting (at: 4pm 24th Jan)
+3. [D][ ] submit project (by: 11 30pm 30th Jan)
+----------------------------------------------------
+
+----------------------------------------------------
+Task is marked as done.
+[D][X] submit project (by: 11 30pm 30th Jan)
+----------------------------------------------------
+
+----------------------------------------------------
+Task is marked as not done.
+[E][ ] attend meeting (at: 4pm 24th Jan)
+----------------------------------------------------
+
+----------------------------------------------------
+1. [T][ ] get a haircut
+2. [E][ ] attend meeting (at: 4pm 24th Jan)
+3. [D][X] submit project (by: 11 30pm 30th Jan)
+----------------------------------------------------
+
+----------------------------------------------------
+Goodbye! See you soon. :)
+----------------------------------------------------
diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt
index e69de29bb2..b0f2a5eec3 100644
--- a/text-ui-test/input.txt
+++ b/text-ui-test/input.txt
@@ -0,0 +1,10 @@
+todo get a haircut
+event attend meeting /at 4pm 24th Jan
+list
+deadline submit project /by 11 30pm 30th Jan
+mark 2
+list
+mark 3
+unmark 2
+list
+bye
\ No newline at end of file
diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat
index 0873744649..e2d686ccb9 100644
--- a/text-ui-test/runtest.bat
+++ b/text-ui-test/runtest.bat
@@ -7,7 +7,7 @@ REM delete output from previous run
if exist ACTUAL.TXT del ACTUAL.TXT
REM compile the code into the bin folder
-javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java
+javac -cp C:\repos\ip\src\main\java -Xlint:none -d C:\Program Files\Java\jdk-11.0.9\bin C:\repos\ip\src\main\java\*.java
IF ERRORLEVEL 1 (
echo ********** BUILD FAILURE **********
exit /b 1
diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh
old mode 100644
new mode 100755