diff --git a/.gitignore b/.gitignore
index f69985ef1f..826fb5fbd8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ bin/
/text-ui-test/ACTUAL.txt
text-ui-test/EXPECTED-UNIX.TXT
+data/data.txt
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..967d42fc1d
--- /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 {
+ String javaFxVersion = '11.0.1'
+
+ 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'
+
+ 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'
+}
+
+test {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed"
+
+ showExceptions true
+ exceptionFormat "full"
+ showCauses true
+ showStackTraces true
+ showStandardStreams = false
+ }
+}
+
+application {
+ mainClassName = "Launcher"
+}
+
+shadowJar {
+ archiveBaseName = "duke"
+ archiveClassifier = null
+}
+
+checkstyle {
+ toolVersion = '8.32'
+}
+
+run{
+ standardInput = System.in
+}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000000..b1e659a3f8
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,403 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
new file mode 100644
index 0000000000..dcaa1af3c3
--- /dev/null
+++ b/config/checkstyle/suppressions.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/README.md b/docs/README.md
index fd44069597..693ad63517 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,20 +1,193 @@
# User Guide
-## Features
+## Introduction
+Duke is a simple application that helps you keep track of your ToDos, Deadlines and Events all in one list.
-### Feature 1
-Description of feature.
+## List of Features
-## Usage
+**`todo`**: Adds a ToDo task into your list.
-### `Keyword` - Describe action
+**`event`**: Adds an Event task into your list.
-Describe action and its outcome.
+**`deadline`**: Adds a Deadline task into your list.
+
+**`list`**: Lists all tasks in your list.
+
+**`find`**: Lists all tasks in your list that matches the keyword.
+
+**`done`**: Marks a task as done.
+
+**`delete`**: Deletes a task from your list.
+
+**`bye`**: Terminates the Application.
+
+## Usage of Features
+
+#### 1. **`todo`**: Adds a ToDo task ino your list
+- This command adds a ToDo task into your list
+- ToDo task is useful if your task doesn't require any deadline
+
+Format:
+
+`todo `
+
+Example of usage:
+
+`todo CS2103T assignment`
+
+Expected outcome:
+
+```
+Roger. I've added this task:
+[T][✘] CS2103T assignment
+Now you have 1 tasks in the list.
+```
+
+#### 2. **`event`**: Adds an Event task into your list.
+- This command adds an Event task into your list
+- Event task is useful if you need to note down an upcoming event that is happening on a certain day
+- Date format has to be strictly adhered to
+- Description and Date **must** be provided
+
+Format:
+
+`event /at `
+
+Example of usage:
+
+`event Brian's birthday /at 4/5/2020`
+
+Expected outcome:
+
+```
+Roger. I've added this task:
+[E][✘] Brian's birthday (by: May 4 2020)
+Now you have 2 tasks in the list.
+```
+
+#### 3. **`deadline`**: Adds a Deadline task into your list.
+- This command adds a Deadline task into your list
+- Deadline task is useful when your ToDo task has a deadline, as suggested by the name itself
+- Deadline format has to be strictly adhered to
+- Description and Deadline **must** be provided
+
+Format:
+
+`deadline /by `
+
+Example of usage:
+
+`deadline CS2103 Lab /by 31/9/2020`
+
+Expected outcome:
+
+```
+Roger. I've added this task:
+[D][✘] CS2103 Lab (by: Sep 30 2020)
+Now you have 3 tasks in the list.
+```
+
+#### 4. **`list`**: Lists all tasks in your list.
+- This command will display all the tasks in your list
+
+Format:
+
+`list`
Example of usage:
-`keyword (optional arguments)`
+`list`
Expected outcome:
-`outcome`
+```
+Here are the tasks in your list:
+1.[T][✘] CS2103T assignment
+2.[E][✘] Brian's birthday (by: May 4 2020)
+3.[D][✘] CS2103 Lab (by: Sep 30 2020)
+```
+
+#### 5. **`find`**: Lists all tasks in your list that matches the keyword.
+- This command lists all the tasks in your list, if any
+- Keyword **must** be provided and it is not case-sensitive
+- All tasks containing the keyword would be listed, even if the keyword matches the task only partially, as shown in the example below
+
+
+Format:
+
+`find `
+
+Example of usage:
+
+`find 2103`
+
+Expected outcome:
+
+```
+Here are the matching tasks in your list:
+1.[T][✘] CS2103T assignment
+2.[D][✘] CS2103 Lab (by: Sep 30 2020)
+```
+
+#### 6. **`done`**: Marks a task as done.
+- This command marks your task as done
+- This is indicated by the change from [✘] to [✓]
+- Index of the task can be seen using the `list` command
+- Index **must** be provided
+
+Format:
+
+`done `
+
+Example of usage:
+
+`done 1`
+
+Expected outcome:
+
+```
+Nice! I've marked this task as done:
+[T][✓] CS2103T assignment
+```
+
+#### 7. **`delete`**: Deletes a task from your list.
+- This command deletes task from your list
+- You can also delete multiple tasks from your list
+- Index / Indexes **must** be provided
+
+Format:
+
+`delete ` or `delete `
+
+Example of usage:
+
+Case 1: `delete 1`
+
+Case 2: `delete 2,3`
+
+Expected outcome:
+
+Case 1:
+```
+Alright! I've removed this task:
+[T][✓] CS2103T assignment
+Now you have 2 tasks in the list.
+```
+Case 2:
+```
+Alright! I've removed the following tasks:
+1.[E][✘] Brian's birthday (by: May 4 2020)
+2.[D][✘] CS2103 Lab (by: Sep 30 2020)
+Now you have 0 tasks in the list.
+```
+
+#### 8. **`bye`**: Terminates the Application.
+- This command terminates Duke application.
+
+Format:
+
+`bye`
+
+Example of usage:
+
+`bye`
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..983b3332f8
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..b51a045953
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sun Sep 06 22:48:03 SGT 2020
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
new file mode 100644
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/DialogBox.java b/src/main/java/DialogBox.java
new file mode 100644
index 0000000000..7284f47acb
--- /dev/null
+++ b/src/main/java/DialogBox.java
@@ -0,0 +1,59 @@
+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;
+
+import java.io.IOException;
+import java.util.Collections;
+
+/**
+ * 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) {
+ DialogBox db = new DialogBox(text, img);
+ db.flip();
+ return db;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java
index 5d313334cc..82b9dcd875 100644
--- a/src/main/java/Duke.java
+++ b/src/main/java/Duke.java
@@ -1,10 +1,78 @@
+import duke.Command;
+import duke.DukeException;
+import duke.Parser;
+import duke.Storage;
+import duke.TaskList;
+import duke.Ui;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Duke is a application that helps you keep track of your ToDos, Deadlines and Events all in one list.
+ */
public class Duke {
+ private Storage storage;
+ private TaskList taskList;
+
+ /**
+ * Initialises taskList and storage of Duke
+ */
+ public Duke() {
+ String filePath = "./data";
+ String fileName = "data.txt";
+ this.storage = new Storage(filePath + "/" + fileName);
+ try {
+ File dir = new File(filePath);
+ File file = new File(filePath, fileName);
+ if (dir.exists() && file.exists()) {
+ this.taskList = new TaskList(storage.load());
+ } else if (dir.exists()) {
+ createFile();
+ } else {
+ createDirectory(dir);
+ createFile();
+ }
+ } catch (DukeException e) {
+ Ui.printException(e);
+ System.exit(1);
+ }
+ }
+
+ private void createDirectory(File dir) {
+ dir.mkdir();
+ }
+
+ private void createFile() throws DukeException {
+ try {
+ storage.createFile();
+ this.taskList = new TaskList();
+ } catch (IOException e) {
+ throw new DukeException("Error Creating File");
+ }
+ }
+
+ /**
+ * Complements the implementation of JavaFX.
+ *
+ * @param input User input.
+ * @return A string.
+ */
+ String getResponse(String input) {
+ Command command;
+ try {
+ if (Parser.isBye(input)) {
+ this.storage.save(this.taskList);
+ System.exit(0);
+ }
+ command = Parser.parseInput(input, taskList);
+ return command.execute();
+ } catch (DukeException e) {
+ return Ui.printException(e);
+ }
+ }
+
public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
+ new Duke();
}
}
diff --git a/src/main/java/Launcher.java b/src/main/java/Launcher.java
new file mode 100644
index 0000000000..11dbf00c62
--- /dev/null
+++ b/src/main/java/Launcher.java
@@ -0,0 +1,10 @@
+import javafx.application.Application;
+
+/**
+ * A launcher class to workaround classpath issues.
+ */
+public class Launcher {
+ public static void main(String[] args) {
+ Application.launch(Main.class, args);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
new file mode 100644
index 0000000000..dca7732b26
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,29 @@
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+
+/**
+ * A GUI for Duke using FXML.
+ */
+public class Main extends Application {
+
+ private Duke duke = new Duke();
+
+ @Override
+ public void start(Stage stage) {
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
+ AnchorPane ap = fxmlLoader.load();
+ Scene scene = new Scene(ap);
+ stage.setScene(scene);
+ fxmlLoader.getController().setDuke(duke);
+ stage.show();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/MainWindow.java b/src/main/java/MainWindow.java
new file mode 100644
index 0000000000..3fe83372de
--- /dev/null
+++ b/src/main/java/MainWindow.java
@@ -0,0 +1,56 @@
+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 Duke duke;
+
+ private Image userImage = new Image(this.getClass().getResourceAsStream("/images/User.png"));
+ private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/Duke.png"));
+
+ @FXML
+ public void initialize() {
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ }
+
+ public void setDuke(Duke d) {
+ duke = d;
+ greetUser();
+ }
+
+ /**
+ * 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 = duke.getResponse(input);
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, userImage),
+ DialogBox.getDukeDialog(response, dukeImage)
+ );
+ userInput.clear();
+ }
+
+ private void greetUser() {
+ String greetings = "Hi there! I'm Duke, your personal assistant.\nHow may I help you?";
+ dialogContainer.getChildren().add(DialogBox.getDukeDialog(greetings, dukeImage));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/duke/AddCommand.java b/src/main/java/duke/AddCommand.java
new file mode 100644
index 0000000000..70c587dff2
--- /dev/null
+++ b/src/main/java/duke/AddCommand.java
@@ -0,0 +1,161 @@
+package duke;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeParseException;
+
+/**
+ * AddCommand is used when the user intends to add a task to the TaskList.
+ */
+public class AddCommand extends Command {
+ public AddCommand(int commandType, TaskList taskList, String userInput) {
+ super(commandType, taskList, userInput);
+ }
+
+ /**
+ * Adds a specific task to the TaskList based on user input.
+ *
+ * @return Description of the specific task added.
+ * @throws DukeException If this method is called on an invalid AddCommand.
+ */
+ public String execute() throws DukeException {
+ String[] parsedInput = userInput.split(Parser.SPACE, 2);
+ Task newTask;
+ if (getCommandType() == Command.CREATE_TODO) {
+ newTask = createToDo(parsedInput);
+ } else if (getCommandType() == Command.CREATE_DEADLINE) {
+ newTask = createDeadline(parsedInput);
+ } else if (getCommandType() == Command.CREATE_EVENT) {
+ newTask = createEvent(parsedInput);
+ } else {
+ throw new DukeException("Invalid Add Command!");
+ }
+
+ return addTaskAndPrint(newTask);
+ }
+
+ /**
+ * Adds the given task to TaskList and prints the Description of that task.
+ *
+ * @param newTask The task to be added to taskList.
+ * @return Description of the task.
+ */
+ private String addTaskAndPrint(Task newTask) {
+ taskList.add(newTask);
+ String userMessage = Ui.informNewTask(newTask) + Ui.informNumberOfTasksRemaining(taskList);
+ return userMessage;
+ }
+
+ /**
+ * Creates a ToDo task.
+ *
+ * @param parsedInput Input of the user parsed into tokens.
+ * @return New ToDo task.
+ * @throws DukeException If format of user input is incorrect.
+ */
+ private Task createToDo(String[] parsedInput) throws DukeException {
+ if (isValidFormat(parsedInput, Command.CREATE_TODO)) {
+ String taskDescription = parsedInput[1].trim();
+ return new ToDo(taskDescription);
+ } else {
+ throw new DukeException("Invalid Todo Format!");
+ }
+ }
+
+ /**
+ * Creates a Deadline task.
+ *
+ * @param parsedInput Input of the user parsed into tokens.
+ * @return New Deadline task.
+ * @throws DukeException If format of user input is incorrect.
+ */
+ private Task createDeadline(String[] parsedInput) throws DukeException {
+ if (isValidFormat(parsedInput, Command.CREATE_DEADLINE)) {
+ String description = parsedInput[1];
+ String[] detailsAndDate = description.split("/by");
+ String details = detailsAndDate[0].trim();
+ String date = detailsAndDate[1].trim();
+ LocalDate formattedDate = LocalDate.parse(date, TimedTask.DATE_FORMATTER);
+ return new Deadline(details, formattedDate);
+ } else {
+ throw new DukeException("Invalid Deadline Format! Please include Deadline details and "
+ + "Date should be in D/M/YYYY");
+ }
+ }
+
+ /**
+ * Creates an Event task.
+ *
+ * @param parsedInput Input of the user parsed into tokens.
+ * @return New Event task.
+ * @throws DukeException If format of the user input is incorrect
+ */
+ private Task createEvent(String[] parsedInput) throws DukeException {
+ if (isValidFormat(parsedInput, Command.CREATE_EVENT)) {
+ String description = parsedInput[1];
+ String[] detailsAndDate = description.split("/at");
+ String details = detailsAndDate[0].trim();
+ String date = detailsAndDate[1].trim();
+ LocalDate formattedDate = LocalDate.parse(date, TimedTask.DATE_FORMATTER);
+ return new Event(details, formattedDate);
+ } else {
+ throw new DukeException("Invalid Event Format! Please include Event details and "
+ + "Date should be in D/M/YYYY");
+ }
+ }
+
+ /**
+ * Checks if user input is in a valid format supported by Duke.
+ *
+ * @param parsedInput User input parsed into tokens.
+ * @param commandType Specific type of the Add Command.
+ * @return True if user input is in a valid format.
+ */
+ private boolean isValidFormat(String[] parsedInput, int commandType) {
+ boolean missingDescription = parsedInput.length < 2;
+ if (missingDescription) {
+ return false;
+ }
+
+ String description = parsedInput[1];
+
+ if (description.isBlank()) {
+ return false;
+ }
+
+ if (commandType == Command.CREATE_TODO) {
+ return parsedInput.length == 2 && description != Parser.EMPTY_STRING;
+ } else {
+ String[] detailsAndDate;
+ if (commandType == Command.CREATE_DEADLINE) {
+ detailsAndDate = description.split("/by");
+ } else if (commandType == Command.CREATE_EVENT) {
+ detailsAndDate = description.split("/at");
+ } else {
+ return false;
+ }
+
+ if (detailsAndDate.length < 2) {
+ return false;
+ }
+
+ String details = detailsAndDate[0].trim();
+ String date = detailsAndDate[1].trim();
+ return detailsAndDate.length == 2 && isValidTimeFormat(date) && !details.isBlank();
+ }
+ }
+
+ /**
+ * Checks if the date given in user input is of valid format supported by Duke.
+ *
+ * @param date Date given in user input for Task.
+ * @return True if the date is in the correct D/M/YYYY format.
+ */
+ private boolean isValidTimeFormat(String date) {
+ try {
+ LocalDate.parse(date, TimedTask.DATE_FORMATTER);
+ return true;
+ } catch (DateTimeParseException e) {
+ return false;
+ }
+ }
+}
diff --git a/src/main/java/duke/Command.java b/src/main/java/duke/Command.java
new file mode 100644
index 0000000000..3f3c302743
--- /dev/null
+++ b/src/main/java/duke/Command.java
@@ -0,0 +1,61 @@
+package duke;
+
+/**
+ * Command encapsulates what the user intends to do based on the user's input.
+ */
+public abstract class Command {
+ /**
+ * Types of Commands supported by Duke.
+ */
+ public static final int LIST = 1;
+ public static final int DONE = 2;
+ public static final int DELETE = 3;
+ public static final int FIND = 4;
+ public static final int INVALID = 99;
+ public static final int CREATE_TODO = 11;
+ public static final int CREATE_DEADLINE = 12;
+ public static final int CREATE_EVENT = 13;
+
+ private int commandType;
+ protected Storage storage;
+ protected TaskList taskList;
+ protected String userInput;
+
+ public Command(int commandType) {
+ this.commandType = commandType;
+ }
+
+ public Command(int commandType, Storage storage, TaskList taskList) {
+ this.commandType = commandType;
+ this.storage = storage;
+ this.taskList = taskList;
+ }
+
+ public Command(int commandType, TaskList taskList, String userInput) {
+ this.commandType = commandType;
+ this.taskList = taskList;
+ this.userInput = userInput;
+ }
+
+ public Command(int commandType, TaskList taskList) {
+ this.commandType = commandType;
+ this.taskList = taskList;
+ }
+
+ /**
+ * Getter method for commandType.
+ *
+ * @return Type of command in integer form.
+ */
+ public int getCommandType() {
+ return this.commandType;
+ }
+
+ /**
+ * An abstract method implemented by the subclasses.
+ *
+ * @return String describing the outcome after executing the specific command.
+ * @throws DukeException If an error occurs during the execution of command.
+ */
+ public abstract String execute() throws DukeException;
+}
diff --git a/src/main/java/duke/Deadline.java b/src/main/java/duke/Deadline.java
new file mode 100644
index 0000000000..6eb19e3ebb
--- /dev/null
+++ b/src/main/java/duke/Deadline.java
@@ -0,0 +1,27 @@
+package duke;
+
+import java.time.LocalDate;
+
+/**
+ * Deadline is a form of TimedTask and it contains a description, status and date (deadline).
+ */
+public class Deadline extends TimedTask {
+
+ public Deadline(String description, LocalDate date) {
+ super(description, date);
+ }
+
+ public Deadline(String description, boolean isDone, LocalDate date) {
+ super(description, isDone, date);
+ }
+
+ @Override
+ public String toText() {
+ return super.toText("D");
+ }
+
+ @Override
+ public String toString() {
+ return super.toString("D");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/duke/DeleteCommand.java b/src/main/java/duke/DeleteCommand.java
new file mode 100644
index 0000000000..3f39e3cea4
--- /dev/null
+++ b/src/main/java/duke/DeleteCommand.java
@@ -0,0 +1,111 @@
+package duke;
+
+public class DeleteCommand extends Command {
+ public DeleteCommand(TaskList taskList, String input) {
+ super(Command.DELETE, taskList, input);
+ }
+
+ /**
+ * Deletes the task specified by user from the TaskList.
+ *
+ * @return Description of the task deleted.
+ * @throws DukeException If there are missing information in the user input.
+ */
+ public String execute() throws DukeException {
+ String[] parsedInput = userInput.split(Parser.SPACE);
+ if (isValidSingleArgumentFormat(parsedInput)) {
+ return deleteTask(parsedInput[1]);
+ } else if (isValidMultipleArgumentsFormat(parsedInput)) {
+ return deleteMultipleTasks(parsedInput[1]);
+ } else {
+ throw new DukeException("You forgot to include the task index or your task index is out of range.");
+ }
+ }
+
+ /**
+ * Deletes a task
+ *
+ * @param s Contains the index of the task to be deleted in String.
+ * @return Description of the task deleted.
+ */
+ private String deleteTask(String s) {
+ int taskIndex = Integer.parseInt(s) - 1;
+ return deleteTaskFromTaskList(taskIndex);
+ }
+
+ private String deleteTaskFromTaskList(int taskIndex) {
+ Task selectedTask = taskList.get(taskIndex);
+ taskList.remove(taskIndex);
+ String userMessage = Ui.informTaskDeleted(selectedTask) + Ui.informNumberOfTasksRemaining(taskList);
+ return userMessage;
+ }
+
+ /**
+ * Deletes more than one tasks.
+ *
+ * @param taskIndexArguments Contains the indexes of the tasks to be deleted in String.
+ * @return Description of the tasks deleted.
+ */
+ private String deleteMultipleTasks(String taskIndexArguments) {
+ String[] taskIndexes = taskIndexArguments.split(Parser.COMMA);
+ Task[] tasksToDelete = new Task[taskIndexes.length];
+ return deleteTasksFromTaskList(taskIndexes, tasksToDelete);
+ }
+
+ private String deleteTasksFromTaskList(String[] taskIndexes, Task[] tasksToDelete) {
+ for (int i = 0; i < taskIndexes.length; i++) {
+ int taskIndex = Integer.parseInt(taskIndexes[i]) - 1;
+ Task selectedTask = taskList.get(taskIndex);
+ tasksToDelete[i] = selectedTask;
+ }
+ for (int i = 0; i < tasksToDelete.length; i++) {
+ taskList.remove(tasksToDelete[i]);
+ }
+ String userMessage = Ui.informTasksDeleted(tasksToDelete) + Ui.informNumberOfTasksRemaining(taskList);
+ return userMessage;
+ }
+
+ /**
+ * Checks if the user input is in a valid format supported by Duke when the user is deleting one task.
+ *
+ * @param inputArr Refers to the parsed user input.
+ * @return True if the user input is in a valid format.
+ */
+ private boolean isValidSingleArgumentFormat(String[] inputArr) {
+ try {
+ int taskIndex = Integer.parseInt(inputArr[1]);
+ if (taskIndex > taskList.size()) {
+ return false;
+ }
+ return inputArr.length == 2;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Checks if the user input is in a valid format supported by Duke when the user is deleting more than one task.
+ *
+ * @param inputArr Refers to the parsed user input.
+ * @return True if the user input is in a valid format.
+ */
+ private boolean isValidMultipleArgumentsFormat(String[] inputArr) {
+ String deleteArgument = inputArr[1];
+ String[] deleteTaskIndexes = deleteArgument.split(Parser.COMMA);
+ if (deleteTaskIndexes.length == 0) {
+ return false;
+ }
+ try {
+ boolean indexesWithinRange = true;
+ for (int i = 0; i < deleteTaskIndexes.length; i++) {
+ int taskIndex = Integer.parseInt(deleteTaskIndexes[i].trim());
+ if (taskIndex > taskList.size()) {
+ indexesWithinRange = false;
+ }
+ }
+ return indexesWithinRange;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/duke/DoneCommand.java b/src/main/java/duke/DoneCommand.java
new file mode 100644
index 0000000000..00031b145a
--- /dev/null
+++ b/src/main/java/duke/DoneCommand.java
@@ -0,0 +1,54 @@
+package duke;
+
+public class DoneCommand extends Command {
+ public DoneCommand(TaskList taskList, String input) {
+ super(Command.DONE, taskList, input);
+ }
+
+ /**
+ * Marks the task specified by user as done.
+ *
+ * @return Message informing user that the task is marked as done.
+ * @throws DukeException If user did not provide index of the task to be marked as done.
+ */
+ public String execute() throws DukeException {
+ try {
+ String[] parsedInput = userInput.split(Parser.SPACE);
+ if (isValidFormat(parsedInput)) {
+ int taskIndex = Integer.parseInt(parsedInput[1]) - 1;
+ return markTaskAsDone(taskIndex);
+ } else {
+ throw new DukeException("You forgot to include the task index..");
+ }
+ } catch (DukeException e) {
+ throw e;
+ }
+
+ }
+
+ private String markTaskAsDone(int taskIndex) throws DukeException {
+ try {
+ Task selectedTask = taskList.get(taskIndex);
+ selectedTask.markAsDone();
+ String userMessage = Ui.informTaskDone(selectedTask);
+ return userMessage;
+ } catch (IndexOutOfBoundsException e) {
+ throw new DukeException("Please enter a valid index!");
+ }
+ }
+
+ /**
+ * Checks if the user input is in a valid format supported by Duke.
+ *
+ * @param inputArr The array containing parsed user input.
+ * @return True if the user input is in a valid format.
+ */
+ private boolean isValidFormat(String[] inputArr) {
+ try {
+ int checkIfArgumentIsInteger = Integer.parseInt(inputArr[1]);
+ return inputArr.length == 2;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+}
diff --git a/src/main/java/duke/DukeException.java b/src/main/java/duke/DukeException.java
new file mode 100644
index 0000000000..4e04da3e54
--- /dev/null
+++ b/src/main/java/duke/DukeException.java
@@ -0,0 +1,10 @@
+package duke;
+
+/**
+ * DukeException is a form of Exception used by Duke methods when a problem arises.
+ */
+public class DukeException extends Exception {
+ public DukeException(String s) {
+ super(s);
+ }
+}
diff --git a/src/main/java/duke/Event.java b/src/main/java/duke/Event.java
new file mode 100644
index 0000000000..c6de9977b1
--- /dev/null
+++ b/src/main/java/duke/Event.java
@@ -0,0 +1,27 @@
+package duke;
+
+import java.time.LocalDate;
+
+/**
+ * Event is a form of TimedTask and it contains a description, status and date.
+ */
+public class Event extends TimedTask {
+
+ public Event(String description, LocalDate date) {
+ super(description, date);
+ }
+
+ public Event(String description, LocalDate date, boolean isDone) {
+ super(description, isDone, date);
+ }
+
+ @Override
+ public String toText() {
+ return super.toText("E");
+ }
+
+ @Override
+ public String toString() {
+ return super.toString("E");
+ }
+}
diff --git a/src/main/java/duke/FindCommand.java b/src/main/java/duke/FindCommand.java
new file mode 100644
index 0000000000..021942023e
--- /dev/null
+++ b/src/main/java/duke/FindCommand.java
@@ -0,0 +1,55 @@
+package duke;
+
+public class FindCommand extends PrintTaskCommand {
+ public FindCommand(TaskList tasklist, String input) {
+ super(Command.FIND, tasklist, input);
+ }
+
+ /**
+ * Returns all the matching tasks
+ *
+ * @return String containing the description of all matching tasks.
+ * @throws DukeException If no keyword was provided by user.
+ */
+ public String execute() throws DukeException {
+ if (isValidFormat(userInput)) {
+ TaskList newTaskList = createListOfTasksContainingKeyword();
+ if (newTaskList.size() == 0) {
+ return Ui.informNoTaskFound();
+ }
+ return outputTasksInTaskList(newTaskList, true);
+ } else {
+ throw new DukeException("What are you trying to find??");
+ }
+ }
+
+ /**
+ * Checks if the user input is in a valid format supported by Duke.
+ *
+ * @param input Input of the User.
+ * @return True if user input is in valid format.
+ */
+ private boolean isValidFormat(String input) {
+ String[] parsedInput = input.split(Parser.SPACE);
+ return parsedInput.length == 2;
+ }
+
+ /**
+ * Creates a new TaskList with only tasks that contains the keyword.
+ *
+ * @return New TaskList.
+ */
+ private TaskList createListOfTasksContainingKeyword() {
+ String[] parsedInput = userInput.split(Parser.SPACE);
+ String keyword = parsedInput[1].toLowerCase();
+ TaskList listOfTasksContainingKeyword = new TaskList();
+ for (int i = 0; i < this.taskList.size(); i++) {
+ Task tempTask = taskList.get(i);
+ String taskDescription = tempTask.getDescription().toLowerCase();
+ if (taskDescription.contains(keyword)) {
+ listOfTasksContainingKeyword.add(tempTask);
+ }
+ }
+ return listOfTasksContainingKeyword;
+ }
+}
diff --git a/src/main/java/duke/InvalidCommand.java b/src/main/java/duke/InvalidCommand.java
new file mode 100644
index 0000000000..9c1382aca5
--- /dev/null
+++ b/src/main/java/duke/InvalidCommand.java
@@ -0,0 +1,16 @@
+package duke;
+
+public class InvalidCommand extends Command {
+ public InvalidCommand() {
+ super(Command.INVALID);
+ }
+
+ /**
+ * Informs the User that the Command is invalid.
+ *
+ * @return String message informing the user.
+ */
+ public String execute() {
+ return Ui.informInvalidCommand();
+ }
+}
diff --git a/src/main/java/duke/ListCommand.java b/src/main/java/duke/ListCommand.java
new file mode 100644
index 0000000000..1aafe4d68e
--- /dev/null
+++ b/src/main/java/duke/ListCommand.java
@@ -0,0 +1,16 @@
+package duke;
+
+public class ListCommand extends PrintTaskCommand {
+ public ListCommand(TaskList tasklist) {
+ super(Command.LIST, tasklist);
+ }
+
+ /**
+ * Prints all the tasks in the TaskList.
+ *
+ * @return Description of all the Tasks in TaskList.
+ */
+ public String execute() {
+ return outputTasksInTaskList(this.taskList, false);
+ }
+}
diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java
new file mode 100644
index 0000000000..163b0661a5
--- /dev/null
+++ b/src/main/java/duke/Parser.java
@@ -0,0 +1,54 @@
+package duke;
+
+/**
+ * Parser helps to handle the user input and classify them into a specific Command.
+ */
+public class Parser {
+
+ public static final String SPACE = " ";
+ public static final String EMPTY_STRING = "";
+ public static final String COMMA = ",";
+
+ /**
+ * Checks if the Input is a termination command.
+ *
+ * @param input Input of the user.
+ * @return True if input is a termination command.
+ */
+ public static boolean isBye(String input) {
+ String firstWord = input.split(SPACE, 2)[0];
+ return firstWord.equals("bye");
+ }
+
+ /**
+ * Parses the userInput and returns a specific command based on the input.
+ *
+ * @param input Input of the user.
+ * @param taskList TaskList of the program.
+ * @return Specific Command related to the user input.
+ */
+ public static Command parseInput(String input, TaskList taskList) {
+ Command command;
+
+ String firstWord = input.split(SPACE, 2)[0];
+
+ if (firstWord.equals("list")) {
+ command = new ListCommand(taskList);
+ } else if (firstWord.equals("find")) {
+ command = new FindCommand(taskList, input);
+ } else if (firstWord.equals("done")) {
+ command = new DoneCommand(taskList, input);
+ } else if (firstWord.equals("delete")) {
+ command = new DeleteCommand(taskList, input);
+ } else if (firstWord.equals("todo")) {
+ command = new AddCommand(Command.CREATE_TODO, taskList, input);
+ } else if (firstWord.equals("deadline")) {
+ command = new AddCommand(Command.CREATE_DEADLINE, taskList, input);
+ } else if (firstWord.equals("event")) {
+ command = new AddCommand(Command.CREATE_EVENT, taskList, input);
+ } else {
+ command = new InvalidCommand();
+ }
+ return command;
+ }
+}
diff --git a/src/main/java/duke/PrintTaskCommand.java b/src/main/java/duke/PrintTaskCommand.java
new file mode 100644
index 0000000000..98c0adb6a1
--- /dev/null
+++ b/src/main/java/duke/PrintTaskCommand.java
@@ -0,0 +1,34 @@
+package duke;
+
+/**
+ * PrintTaskCommand is a abstract class containing a common method used by Commands that print tasks.
+ */
+public abstract class PrintTaskCommand extends Command {
+ public PrintTaskCommand(int commandType, TaskList tasklist) {
+ super(commandType, tasklist);
+ }
+
+ public PrintTaskCommand(int commandType, TaskList taskList, String userInput) {
+ super(commandType, taskList, userInput);
+ }
+
+ /**
+ * Prints all the tasks in the TaskList provided.
+ *
+ * @param taskList TaskList containing task to print.
+ * @param isFind True if this method is printing tasks related to a keyword and false otherwise.
+ * @return All the tasks in TaskList in String.
+ */
+ public String outputTasksInTaskList(TaskList taskList, boolean isFind) {
+ if (taskList.size() == 0) {
+ return Ui.informNoTaskInList();
+ }
+ String output = String.format("Here are the %stasks in your list:", isFind ? "matching " : "");
+ for (int i = 0; i < taskList.size(); i++) {
+ Task currentTask = taskList.get(i);
+ String num = Integer.toString(i + 1);
+ output += "\n" + num + "." + currentTask;
+ }
+ return output;
+ }
+}
diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java
new file mode 100644
index 0000000000..ff2b8e61f4
--- /dev/null
+++ b/src/main/java/duke/Storage.java
@@ -0,0 +1,154 @@
+package duke;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.time.LocalDate;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+public class Storage {
+ private String filePath;
+
+ public Storage(String filePath) {
+ this.filePath = filePath;
+ }
+
+ /**
+ * Reads all the content in the specified File.
+ *
+ * @param filePath File Path of the specified File that we are reading from.
+ * @return All the file contents in String.
+ * @throws FileNotFoundException If no file is found using the filePath given.
+ */
+ private static String readFileContents(String filePath) throws FileNotFoundException {
+ File f = new File(filePath);
+ String fileContentsInString = "";
+ Scanner scanner = new Scanner(f);
+ while (scanner.hasNext()) {
+ fileContentsInString += scanner.nextLine() + System.lineSeparator();
+ }
+ scanner.close();
+ return fileContentsInString;
+ }
+
+ private static ArrayList createTaskList(String content) throws DukeException {
+ ArrayList newTaskList = new ArrayList<>();
+ Scanner scanner = new Scanner(content);
+ while (scanner.hasNext()) {
+ String lineOfText = scanner.nextLine();
+ String[] splitText = lineOfText.split("\\|");
+ String typeOfTask = splitText[0].trim();
+ int statusOfTask = Integer.parseInt(splitText[1].trim());
+ String taskDescription = splitText[2].trim();
+ if (typeOfTask.equals("T")) {
+ createTodoTask(newTaskList, statusOfTask, taskDescription);
+ } else {
+ String date = splitText[3].trim();
+ if (typeOfTask.equals("D")) {
+ createTimedTask(newTaskList, statusOfTask, taskDescription, date, Task.Type.DEADLINE);
+ } else if (typeOfTask.equals("E")) {
+ createTimedTask(newTaskList, statusOfTask, taskDescription, date, Task.Type.EVENT);
+ } else {
+ throw new DukeException("Cannot create invalid type of task!");
+ }
+ }
+ }
+ scanner.close();
+ return newTaskList;
+ }
+
+ private static void createTimedTask(ArrayList newTaskList, int statusOfTask, String taskDescription,
+ String date, Task.Type type) {
+ LocalDate formattedDate = LocalDate.parse(date, TimedTask.DATE_FORMATTER);
+ if (type == Task.Type.EVENT) {
+ newTaskList.add(new Event(taskDescription, formattedDate, statusOfTask == Task.DONE));
+ } else {
+ newTaskList.add(new Deadline(taskDescription, statusOfTask == Task.DONE, formattedDate));
+ }
+
+ }
+
+ private static void createTodoTask(ArrayList list, int statusOfTask, String taskDescription) {
+ list.add(new ToDo(taskDescription, statusOfTask == Task.DONE));
+ }
+
+ /**
+ * Creates an ArrayList of Tasks using the contents of the file.
+ *
+ * @return An ArrayList of Tasks.
+ * @throws FileNotFoundException If the file does not exist in the FilePath.
+ */
+ public ArrayList load() throws DukeException {
+ try {
+ String fileContents = Storage.readFileContents(this.filePath);
+ return createTaskList(fileContents);
+ } catch (FileNotFoundException e) {
+ throw new DukeException("File not found!");
+ } catch (DukeException e) {
+ throw e;
+ }
+
+ }
+
+ /**
+ * Creates a file to save all the tasks in the TaskList before terminating the program.
+ *
+ * @throws IOException If the directory of the file being created doesn't exist.
+ */
+ public void createFile() throws IOException {
+ File file = new File(this.filePath);
+ file.createNewFile();
+ }
+
+ /**
+ * Writes data to a File.
+ *
+ * @param filePath Path of the file that we are writing in.
+ * @param textToAdd Content to write into the file.
+ * @throws DukeException If an error occurs during file writing.
+ */
+ private static void writeToFile(String filePath, String textToAdd) throws DukeException {
+ try {
+ FileWriter fw = new FileWriter(filePath);
+ fw.write(textToAdd);
+ fw.close();
+ } catch (IOException e) {
+ throw new DukeException("Error writing to file during Save");
+ }
+ }
+
+ /**
+ * Saves all the tasks in TaskList to a text file.
+ *
+ * @param taskList TaskList containing all the existing tasks entered by user.
+ */
+ public void save(TaskList taskList) throws DukeException {
+ String dataToSave = readDataFromTaskList(taskList);
+ try {
+ writeToFile(this.filePath, dataToSave);
+ } catch (DukeException e) {
+ throw e;
+ }
+ }
+
+ /**
+ * Reads the tasks in TaskList and converts all the Task description into a String.
+ *
+ * @param taskList TaskList containing tasks to read.
+ * @return All the description of the tasks in TaskList in standard form.
+ */
+ private String readDataFromTaskList(TaskList taskList) {
+ String dataToSave = "";
+ for (int i = 0; i < taskList.size(); i++) {
+ Task currentTask = taskList.get(i);
+ if (i == taskList.size() - 1) {
+ dataToSave += currentTask.toText();
+ } else {
+ dataToSave += currentTask.toText() + System.lineSeparator();
+ }
+ }
+ return dataToSave;
+ }
+}
diff --git a/src/main/java/duke/Task.java b/src/main/java/duke/Task.java
new file mode 100644
index 0000000000..6f7b295ddd
--- /dev/null
+++ b/src/main/java/duke/Task.java
@@ -0,0 +1,67 @@
+package duke;
+
+public class Task {
+ protected String description;
+ protected boolean isDone;
+ public static final int DONE = 1;
+ public static final int NOT_DONE = 0;
+
+ /**
+ * Different types of Task.
+ */
+ public enum Type {
+ TODO, DEADLINE, EVENT
+ }
+
+ public Task(String description) {
+ this.description = description;
+ this.isDone = false;
+ }
+
+ public Task(String description, boolean status) {
+ this.description = description;
+ this.isDone = status;
+ }
+
+ /**
+ * Returns a symbol depending on status of task.
+ *
+ * @return Tick or cross symbol.
+ */
+ public String getStatusIcon() {
+ return (isDone ? "\u2714" : "\u2718"); //return tick or X symbols
+ }
+
+ /**
+ * Getter method for description.
+ *
+ * @return Description of task.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void markAsDone() {
+ this.isDone = true;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + this.getStatusIcon() + "] " + this.getDescription();
+ }
+
+ public String toText() {
+ return toText("T");
+ }
+
+ /**
+ * Converts the Task into standard form for ease of saving to data file.
+ *
+ * @param type Indicates the type of task.
+ * @return Description of Task in standard form.
+ */
+ public String toText(String type) {
+ int doneInt = this.isDone ? DONE : NOT_DONE;
+ return String.format("%s | %d | %s", type, doneInt, this.description);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/duke/TaskList.java b/src/main/java/duke/TaskList.java
new file mode 100644
index 0000000000..f6c565be78
--- /dev/null
+++ b/src/main/java/duke/TaskList.java
@@ -0,0 +1,64 @@
+package duke;
+
+import java.util.ArrayList;
+
+/**
+ * TaskList stores all the tasks entered by the user.
+ */
+public class TaskList {
+ private ArrayList mainList;
+
+ public TaskList(ArrayList mainList) {
+ this.mainList = mainList;
+ }
+
+ public TaskList() {
+ this.mainList = new ArrayList();
+ }
+
+ /**
+ * Adds task to TaskList.
+ *
+ * @param task Task to add.
+ */
+ public void add(Task task) {
+ this.mainList.add(task);
+ }
+
+ /**
+ * Removes task from TaskList.
+ *
+ * @param index Index of task in TaskList to remove.
+ */
+ public void remove(int index) {
+ this.mainList.remove(index);
+ }
+
+ /**
+ * Removes task from TaskList
+ *
+ * @param task The specific task in TaskList to remove.
+ */
+ public void remove(Task task) {
+ this.mainList.remove(task);
+ }
+
+ /**
+ * Gets the task in the TaskList.
+ *
+ * @param index Index of task in TaskList to get.
+ * @return Task.
+ */
+ public Task get(int index) {
+ return this.mainList.get(index);
+ }
+
+ /**
+ * Gets the size of TaskList.
+ *
+ * @return Size of TaskList.
+ */
+ public int size() {
+ return this.mainList.size();
+ }
+}
diff --git a/src/main/java/duke/TimedTask.java b/src/main/java/duke/TimedTask.java
new file mode 100644
index 0000000000..05f35e2819
--- /dev/null
+++ b/src/main/java/duke/TimedTask.java
@@ -0,0 +1,50 @@
+package duke;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * TimedTask is a form of Task that contains an additional date parameter
+ */
+public class TimedTask extends Task {
+
+ public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("d/M/yyyy");
+ public static final DateTimeFormatter OUTPUT_DATE_FORMATTER = DateTimeFormatter.ofPattern("MMM d yyyy");
+
+ protected LocalDate date;
+
+ TimedTask(String description, LocalDate date) {
+ super(description);
+ this.date = date;
+ }
+
+ TimedTask(String description, boolean isDone, LocalDate date) {
+ super(description, isDone);
+ this.date = date;
+ }
+
+ /**
+ * Converts the TimedTask into standard form for ease of saving to data file.
+ *
+ * @param taskLetter taskLetter indicates the type of task.
+ * @return Description of TimedTask in standard form.
+ */
+ @Override
+ public String toText(String taskLetter) {
+ String str = super.toText(taskLetter);
+ str += "| " + this.date.format(DATE_FORMATTER);
+ return str;
+ }
+
+ /**
+ * Prints the TimedTask
+ *
+ * @param taskLetter taskLetter indicates the type of task.
+ * @return Description of TimedTask.
+ */
+ public String toString(String taskLetter) {
+ String dateFormatted = date.format(OUTPUT_DATE_FORMATTER);
+ return String.format("[%s]%s (by: %s)", taskLetter, super.toString(), dateFormatted);
+ }
+
+}
diff --git a/src/main/java/duke/ToDo.java b/src/main/java/duke/ToDo.java
new file mode 100644
index 0000000000..79ce06c8e7
--- /dev/null
+++ b/src/main/java/duke/ToDo.java
@@ -0,0 +1,19 @@
+package duke;
+
+/**
+ * ToDo is a form of task and it contains description and status.
+ */
+public class ToDo extends Task {
+ public ToDo(String description) {
+ super(description);
+ }
+
+ public ToDo(String description, boolean status) {
+ super(description, status);
+ }
+
+ @Override
+ public String toString() {
+ return "[T]" + super.toString();
+ }
+}
diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java
new file mode 100644
index 0000000000..d94447af47
--- /dev/null
+++ b/src/main/java/duke/Ui.java
@@ -0,0 +1,86 @@
+package duke;
+
+public class Ui {
+
+ /**
+ * Returns message of Duke Exception.
+ *
+ * @param e DukeException
+ * @return Message of exception in String
+ */
+ public static String printException(DukeException e) {
+ String errorMessage = "Whoops! Something went wrong...\n" + e.getMessage();
+ return errorMessage;
+ }
+
+ /**
+ * Informs user that the task is marked as done.
+ *
+ * @param task Task that is marked as done.
+ */
+ public static String informTaskDone(Task task) {
+ return "Nice! I've marked this task as done:\n" + task;
+ }
+
+ /**
+ * Informs user that the task is deleted.
+ *
+ * @param task Task that was deleted.
+ */
+ public static String informTaskDeleted(Task task) {
+ return "Alright! I've removed this task:\n" + task;
+ }
+
+ /**
+ * Informs user that the tasks are deleted.
+ *
+ * @param tasks Tasks that were deleted.
+ */
+ public static String informTasksDeleted(Task[] tasks) {
+ String userMessage = "Alright! I've removed the following tasks:\n";
+ for (int i = 0; i < tasks.length; i++) {
+ int taskNumber = i + 1;
+ userMessage += String.format("%d. %s\n", taskNumber, tasks[i]);
+ }
+ return userMessage;
+ }
+
+ /**
+ * Informs user the number of tasks left in TaskList.
+ *
+ * @param taskList TaskList containing tasks.
+ */
+ public static String informNumberOfTasksRemaining(TaskList taskList) {
+ return "\nNow you have " + taskList.size() + " tasks in the list.";
+ }
+
+ /**
+ * Informs user the new task was added.
+ *
+ * @param task New task added.
+ */
+ public static String informNewTask(Task task) {
+ return "Roger. I've added this task:\n" + task;
+ }
+
+ /**
+ * Informs user of the invalid user input.
+ */
+ public static String informInvalidCommand() {
+ return "I'm sorry, but I don't know what that means :(";
+ }
+
+ /**
+ * Informs user no matching tasks was found.
+ */
+ public static String informNoTaskFound() {
+ return "Sorry, no matching task was found!";
+ }
+
+ /**
+ * Informs user no task in TaskList.
+ */
+ public static String informNoTaskInList() {
+ return "Your list is empty at the moment!";
+ }
+}
diff --git a/src/main/resources/images/Duke.png b/src/main/resources/images/Duke.png
new file mode 100644
index 0000000000..a1149260fb
Binary files /dev/null and b/src/main/resources/images/Duke.png differ
diff --git a/src/main/resources/images/GuyAssistant.jpg b/src/main/resources/images/GuyAssistant.jpg
new file mode 100644
index 0000000000..331ea1c234
Binary files /dev/null and b/src/main/resources/images/GuyAssistant.jpg differ
diff --git a/src/main/resources/images/User.png b/src/main/resources/images/User.png
new file mode 100644
index 0000000000..9f90314f16
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..aa2663e948
--- /dev/null
+++ b/src/main/resources/view/DialogBox.fxml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
new file mode 100644
index 0000000000..5371d2dc80
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/duke/ParserTest.java b/src/test/java/duke/ParserTest.java
new file mode 100644
index 0000000000..fc4759968e
--- /dev/null
+++ b/src/test/java/duke/ParserTest.java
@@ -0,0 +1,100 @@
+package duke;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class ParserTest {
+
+ @Test
+ public void testParsingDeadline() {
+ String input = "deadline homework /by 31/12/2020";
+ int expectedCommandType = Command.CREATE_DEADLINE;
+ TaskList taskList = new TaskList();
+ Command testCommand = Parser.parseInput(input, taskList);
+ assertEquals(expectedCommandType,testCommand.getCommandType());
+ try {
+ String output = testCommand.execute();
+ // executed successfully
+ assertEquals(1,1);
+ } catch (DukeException e) {
+ fail("Parsing has failed");
+ }
+ }
+
+ @Test
+ public void testParsingWrongDeadline() {
+ String input = "deadline homework /by 31-12-2020";
+ int expectedCommandType = Command.CREATE_DEADLINE;
+ TaskList taskList = new TaskList();
+ Command testCommand = Parser.parseInput(input, taskList);
+ assertEquals(expectedCommandType,testCommand.getCommandType());
+ try {
+ String output = testCommand.execute();
+ } catch (DukeException e) {
+ assertEquals(1,1);
+ }
+ }
+
+ @Test
+ public void testParsingEvent() {
+ String input = "event Jean's Birthday /at 2/3/2020";
+ int expectedCommandType = Command.CREATE_EVENT;
+ TaskList taskList = new TaskList();
+ Command testCommand = Parser.parseInput(input, taskList);
+ assertEquals(expectedCommandType,testCommand.getCommandType());
+ try {
+ String output = testCommand.execute();
+ // executed successfully
+ assertEquals(1,1);
+ } catch (DukeException e) {
+ fail("Parsing has failed");
+ }
+ }
+
+ @Test
+ public void testParsingEventWrongDate() {
+ String input = "event Jean's birthday /at 30-12-2020";
+ int expectedCommandType = Command.CREATE_EVENT;
+ TaskList taskList = new TaskList();
+ Command testCommand = Parser.parseInput(input, taskList);
+ assertEquals(expectedCommandType,testCommand.getCommandType());
+ try {
+ String output = testCommand.execute();
+ } catch (DukeException e) {
+ // supposed to throw exception
+ assertEquals(1,1);
+ }
+ }
+ @Test
+ public void testParsingTodo() {
+ String input = "todo homework";
+ int expectedCommandType = Command.CREATE_TODO;
+ TaskList taskList = new TaskList();
+ Command testCommand = Parser.parseInput(input, taskList);
+ assertEquals(expectedCommandType,testCommand.getCommandType());
+ try {
+ String output = testCommand.execute();
+ // executed successfully
+ assertEquals(1,1);
+ } catch (DukeException e) {
+ fail("Parsing has failed");
+ }
+ }
+
+ @Test
+ public void testParsingTodoFail() {
+ String input = "todo";
+ int expectedCommandType = Command.CREATE_TODO;
+ TaskList taskList = new TaskList();
+ Command testCommand = Parser.parseInput(input, taskList);
+ assertEquals(expectedCommandType,testCommand.getCommandType());
+ try {
+ String output = testCommand.execute();
+ } catch (DukeException e) {
+ // supposed to throw exception
+ assertEquals(1,1);
+ }
+ }
+}
diff --git a/src/test/java/duke/TaskListTest.java b/src/test/java/duke/TaskListTest.java
new file mode 100644
index 0000000000..7ee6bff6af
--- /dev/null
+++ b/src/test/java/duke/TaskListTest.java
@@ -0,0 +1,86 @@
+package duke;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.LocalDate;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TaskListTest {
+
+ @Test
+ public void successAddToList() {
+ LocalDate testDate = LocalDate.now();
+ Task task1 = new Task("Task1");
+ Task task2 = new Event("Birthday", testDate);
+ Task task3 = new Deadline("Assignment", testDate);
+ Task task4 = new ToDo("Study for Midterms");
+ TaskList testList = new TaskList();
+ testList.add(task1);
+ testList.add(task2);
+ testList.add(task3);
+ testList.add(task4);
+ assertEquals(testList.size(), 4);
+ }
+
+ @Test
+ public void successDeleteFromListByTask() {
+ LocalDate testDate = LocalDate.now();
+ Task task1 = new Task("Task1");
+ Task task2 = new Event("Birthday", testDate);
+ Task task3 = new Deadline("Assignment", testDate);
+ Task task4 = new ToDo("Study for Midterms");
+ TaskList testList = new TaskList();
+ testList.add(task1);
+ testList.add(task2);
+ testList.add(task3);
+ testList.add(task4);
+ testList.remove(task3);
+ testList.remove(task1);
+ assertEquals(testList.size(), 2);
+ testList.remove(task2);
+ assertEquals(testList.size(), 1);
+ testList.remove(task4);
+ assertEquals(testList.size(), 0);
+ }
+
+ @Test
+ public void successDeleteFromListByIndex() {
+ LocalDate testDate = LocalDate.now();
+ Task task1 = new Task("Task1");
+ Task task2 = new Event("Birthday", testDate);
+ Task task3 = new Deadline("Assignment", testDate);
+ Task task4 = new ToDo("Study for Midterms");
+ TaskList testList = new TaskList();
+ testList.add(task1);
+ testList.add(task2);
+ testList.add(task3);
+ testList.add(task4);
+ testList.remove(3);
+ testList.remove(2);
+ assertEquals(testList.size(), 2);
+ testList.remove(1);
+ assertEquals(testList.size(), 1);
+ testList.remove(0);
+ assertEquals(testList.size(), 0);
+ }
+
+ @Test
+ public void successRetrieveFromList() {
+ LocalDate testDate = LocalDate.now();
+ Task task1 = new Task("Task1");
+ Task task2 = new Event("Birthday", testDate);
+ Task task3 = new Deadline("Assignment", testDate);
+ Task task4 = new ToDo("Study for Midterms");
+ TaskList testList = new TaskList();
+ testList.add(task1);
+ testList.add(task2);
+ testList.add(task3);
+ testList.add(task4);
+ assertEquals(testList.get(0), task1);
+ assertEquals(testList.get(1), task2);
+ assertEquals(testList.get(2), task3);
+ assertEquals(testList.get(3), task4);
+
+ }
+}
diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT
index 657e74f6e7..9ed405d527 100644
--- a/text-ui-test/EXPECTED.TXT
+++ b/text-ui-test/EXPECTED.TXT
@@ -1,7 +1,25 @@
-Hello from
- ____ _
-| _ \ _ _| | _____
-| | | | | | | |/ / _ \
-| |_| | |_| | < __/
-|____/ \__,_|_|\_\___|
-
+Hello! I'm Duke
+What can I do for you?
+Got it. I've added this task:
+ [T][✘] borrow book
+Now you have 1 tasks in the list.
+Got it. I've added this task:
+ [D][✘] return book (by: Sunday)
+Now you have 2 tasks in the list.
+Got it. I've added this task:
+ [E][✘] project meeting (at: Mon 2-4pm)
+Now you have 3 tasks in the list.
+Nice! I've marked this task as done:
+ [D][ ✓] return book (by: Sunday)
+Nice! I've marked this task as done:
+ [T][ ✓] borrow book
+Here are the tasks in your list:
+1.[T][ ✓] borrow book
+2.[D][ ✓] return book (by: Sunday)
+3.[E][✘] project meeting (at: Mon 2-4pm)
+Nice! I've marked this task as done:
+ [E][ ✓] project meeting (at: Mon 2-4pm)
+Here are the tasks in your list:
+1.[T][ ✓] borrow book
+2.[D][ ✓] return book (by: Sunday)
+3.[E][ ✓] project meeting (at: Mon 2-4pm)
diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt
index e69de29bb2..5e31752d03 100644
--- a/text-ui-test/input.txt
+++ b/text-ui-test/input.txt
@@ -0,0 +1,8 @@
+todo borrow book
+deadline return book /by Sunday
+event project meeting /at Mon 2-4pm
+done 2
+done 1
+list
+done 3
+list
diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh
index e169618a34..74ad72b963 100644
--- a/text-ui-test/runtest.sh
+++ b/text-ui-test/runtest.sh
@@ -13,7 +13,7 @@ then
fi
# compile the code into the bin folder, terminates if error occurred
-if ! javac -cp ../src -Xlint:none -d ../bin ../src/main/java/Duke.java
+if ! javac -cp ../src -Xlint:none -d ../bin ../src/main/java/*.java
then
echo "********** BUILD FAILURE **********"
exit 1
@@ -35,4 +35,4 @@ then
else
echo "Test result: FAILED"
exit 1
-fi
\ No newline at end of file
+fi