diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000000..a19c6c8bbe
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index 99712178bf..e2b3b109b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,4 @@ src/main/resources/docs/
# MacOS custom attributes files created by Finder
.DS_Store
*.iml
-bin/
+bin/
\ No newline at end of file
diff --git a/.project b/.project
new file mode 100644
index 0000000000..6fb94a8c8b
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ duke
+ Project duke created by Buildship.
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectbuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.buildship.core.gradleprojectnature
+
+
diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 0000000000..e8895216fd
--- /dev/null
+++ b/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,2 @@
+connection.project.dir=
+eclipse.preferences.version=1
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..b4ae762efb
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,7 @@
+language: java
+matrix:
+ include:
+ - jdk: openjdk11
+
+script: >-
+ ./gradlew clean checkstyleMain checkstyleTest test
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000000..c5f3f6b9c7
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.configuration.updateBuildConfiguration": "interactive"
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..dd04283376
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,64 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'checkstyle'
+ id 'com.github.johnrengelman.shadow' version '5.1.0'
+}
+
+checkstyle {
+ toolVersion = '8.23'
+}
+
+group 'seedu.duke'
+version '0.1.0'
+
+repositories {
+ mavenCentral()
+}
+
+application {
+ // Change this to your main class.
+ mainClassName = "duke.Launcher"
+}
+
+shadowJar {
+ archiveBaseName = "duke"
+ archiveVersion = "0.2"
+ archiveClassifier = null
+ archiveAppendix = null
+}
+
+//@@author zihawkeye-reused
+//Reused from https://github.com/Oscar-B-Liang/duke/pull/6/files with no modifications.
+dependencies {
+ 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'
+ implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-web', version: javaFxVersion, classifier: 'linux'
+
+ testImplementation('org.junit.jupiter:junit-jupiter:5.5.1')
+}
+//@@author
+
+test {
+ useJUnitPlatform()
+
+ testLogging {
+ events = ["passed", "failed", "skipped"]
+ }
+}
\ No newline at end of file
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000000..b1a57ba6c0
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,257 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/duke.txt b/data/duke.txt
new file mode 100644
index 0000000000..0616b27d19
Binary files /dev/null and b/data/duke.txt differ
diff --git a/docs/README.md b/docs/README.md
index fd44069597..c8498ac1d3 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,20 +1,128 @@
# User Guide
+Duke is a todo manager application that is primarily command-line-based.
+
+## Commands
+* Todo
+* Deadline
+* Event
+* Delete
+* Done
+* List
+* Find
+* Undo
## Features
-### Feature 1
-Description of feature.
+### Adding a task
+Adds a new task into Duke. Types of tasks are:
+* Todo - format: todo [TASK_NAME]
+* Deadline - format: deadline [TASK_NAME] /by [DATE]
+* Event - format: event [TASK_NAME] /by [DATE]
+
+[DATE] format is `[DAY]/[MONTH]/[YEAR] [HOUR][MIN]`
+
+Example of usage:
+
+`deadline CS2100 assignment /by 18/09/2019 2359`
+
+Expected outcome:
+
+`Got it. I've added this task:`\
+`[D][✘] CS2100 assignment (by: Wed Sep 18 23:59:00 SGT 2019)`\
+`Now you have 1 tasks in the list.`
+
+### Deleting a task
+Deletes a task in the tasklist as specified by its item id.
+
+### Usage
+
+`delete [TASK_INDEX]`
+
+Example of usage:
+
+`delete 1`
+
+Expected outcome:
+
+`Noted. I've removed this task:`\
+` [D][✘] CS2100 assignment (by: Wed Sep 18 23:59:00 SGT 2019)`\
+`Now you have 0 tasks in the list.`
+
+### List
+Lists all tasks in the tasklist.
+
+### Usage
+
+`list`
+
+Expected outcome:
+
+`Here are the tasks in your list:`\
+`1.[D][✘] CS2100 assignment (by: Wed Sep 18 23:59:00 SGT 2019)`
+
+### Mark as done
+Marks a task in the tasklist as done as specified by its item id.
+
+### Usage
-## Usage
+`done [TASK_INDEX]`
-### `Keyword` - Describe action
+Example of usage:
+
+`done 1`
+
+Expected outcome:
+
+`Nice! I've marked this task as done:`\
+` [D][✓] CS2100 assignment (by: Wed Sep 18 23:59:00 SGT 2019)`
+
+### Find task
+Lists out all the task that completely or partially match a given keyword.
+
+### Usage
-Describe action and its outcome.
+`find [KEYWORD]`
Example of usage:
-`keyword (optional arguments)`
+`find CS`
Expected outcome:
-`outcome`
+`Here are the matching tasks in your list:`\
+` 1.[D][✓] CS2100 assignment (by: Wed Sep 18 23:59:00 SGT 2019)`
+
+### Sort tasks
+Sorts tasks in the tasklist based on the specified field in the tasks.
+
+### Usage
+
+`sort [FIELD]`
+
+[FIELD] can take values `type`, `description`, `date`.
+
+Example of usage:
+
+`sort date`
+
+Expected outcome:
+
+`Here is the sorted list:`\
+` 1.[E][✘] Kennedy's visit to Texas (at: Tue Nov 22 12:30:00 SGT 63)`\
+` 2.[D][✓] CS2100 assignment (by: Wed Sep 18 23:59:00 SGT 2019)`
+
+## Exit program
+Exits the Duke application.
+
+### Usage
+
+`bye`
+
+Example of usage:
+
+`bye`
+
+Expected outcome:
+
+Program exits.
+
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..e0a70bc05c
Binary files /dev/null and b/docs/Ui.png differ
diff --git a/docs/_config.yml b/docs/_config.yml
new file mode 100644
index 0000000000..2f7efbeab5
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-minimal
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..87b738cbd0
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..4b7e1f3d38
--- /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-5.5.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000000..af6708ff22
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## 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"'
+
+# 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, switch paths to Windows format before running java
+if $cygwin ; 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=$((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"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000000..6d57edc706
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@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 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"
+
+@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/settings.gradle b/settings.gradle
new file mode 100644
index 0000000000..d1e92fe5db
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'duke'
diff --git a/src/main/java/DialogBox.java b/src/main/java/DialogBox.java
new file mode 100644
index 0000000000..327cc58ab8
--- /dev/null
+++ b/src/main/java/DialogBox.java
@@ -0,0 +1,73 @@
+package duke;
+
+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);
+ }
+
+ /**
+ * Creates User dialog box.
+ *
+ * @param text Text of user to be displayed.
+ * @param img Image of user to be displayed.
+ */
+ public static DialogBox getUserDialog(String text, Image img) {
+ return new DialogBox(text, img);
+ }
+
+ /**
+ * Creates Duke dialog box.
+ *
+ * @param text Text of Duke to be displayed.
+ * @param img Image of Duke to be displayed.
+ */
+ public static DialogBox getDukeDialog(String text, Image img) {
+ var 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..742a5079f0 100644
--- a/src/main/java/Duke.java
+++ b/src/main/java/Duke.java
@@ -1,10 +1,89 @@
+package duke;
+
+import duke.exception.DukeException;
+import duke.util.Parser;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+import duke.command.Command;
+
+/**
+ * Application class for Duke.
+ */
public class Duke {
+ private static final String SAVE_PATH = "data/duke.txt";
+
+ private Storage storage;
+ private TaskList tasks;
+ private Ui ui;
+
+ /**
+ * Constructor of Duke class without parameters.
+ */
+ public Duke() {
+ this(SAVE_PATH);
+ }
+
+ /**
+ * Constructor of Duke class.
+ *
+ * @param filePath Path to text file where save data is stored.
+ */
+ public Duke(String filePath) {
+ this.ui = new Ui();
+ this.storage = new Storage(filePath);
+ try {
+ this.tasks = this.storage.load();
+ } catch (DukeException e) {
+ this.ui.showLoadingError();
+ this.tasks = new TaskList();
+ }
+ }
+
+ /**
+ * Main method for Duke.
+ *
+ * @param args Arguments entered when main method is executed.
+ */
public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
+ new Duke(SAVE_PATH).run();
+ }
+
+ /**
+ * Returns String as response to user input.
+ *
+ * @param input Input entered by user.
+ */
+ public String getResponse(String input) {
+ try {
+ Command c = Parser.parse(input);
+ c.execute(tasks, ui, storage);
+ this.storage.save(tasks);
+ if (c.isExit()) {
+ System.exit(0);
+ }
+ } catch (DukeException e) {
+ this.ui.showError(e.getMessage());
+ }
+ return this.ui.getOutput();
+ }
+
+ /**
+ * Run method of Duke.
+ */
+ public void run() {
+ this.ui.showWelcome();
+
+ boolean isExit = false;
+ while (!isExit) {
+ try {
+ Command c = Parser.parse(ui.readCommand());
+ c.execute(tasks, ui, storage);
+ storage.save(tasks);
+ isExit = c.isExit();
+ } catch (DukeException e) {
+ ui.showError(e.getMessage());
+ }
+ }
}
}
diff --git a/src/main/java/Launcher.java b/src/main/java/Launcher.java
new file mode 100644
index 0000000000..5483e63637
--- /dev/null
+++ b/src/main/java/Launcher.java
@@ -0,0 +1,12 @@
+package duke;
+
+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..8ed3a0e35d
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,32 @@
+package duke;
+
+import java.io.IOException;
+
+import duke.MainWindow;
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+
+/**
+ * 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..4a7b4f268b
--- /dev/null
+++ b/src/main/java/MainWindow.java
@@ -0,0 +1,62 @@
+package duke;
+
+import duke.util.Ui;
+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/DaUser.png"));
+ private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"));
+
+ /**
+ * Initialization of the main program.
+ */
+ @FXML
+ public void initialize() {
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ Ui ui = new Ui();
+ ui.showWelcome();
+ String welcome = ui.getOutput();
+ dialogContainer.getChildren().add(
+ DialogBox.getDukeDialog(welcome, dukeImage)
+ );
+ }
+
+ public void setDuke(Duke d) {
+ duke = d;
+ }
+
+ /**
+ * 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();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/AddCommand.java b/src/main/java/command/AddCommand.java
new file mode 100644
index 0000000000..ea8c11b816
--- /dev/null
+++ b/src/main/java/command/AddCommand.java
@@ -0,0 +1,47 @@
+package duke.command;
+
+import duke.exception.DukeException;
+import duke.util.Parser;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+import duke.task.Task;
+
+/**
+ * Command containing method for adding Task to TaskList.
+ */
+public class AddCommand extends Command {
+ private Task task;
+
+ /**
+ * Constructor for AddCommand.
+ *
+ * @param task Task to be added.
+ */
+ public AddCommand(Task task) {
+ this.task = task;
+ }
+
+ /**
+ * Adds a Task to the TaskList.
+ *
+ * @param tasks TaskList to add Task to.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage that stores the modified TaskList.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
+ tasks.addTask(this.task);
+ ui.printResponse("Got it. I've added this task:\n "
+ + this.task.toString() + "\n"
+ + "Now you have " + tasks.size() + " tasks in the list.");
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return false so program does not exit.
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/Command.java b/src/main/java/command/Command.java
new file mode 100644
index 0000000000..29494fbea7
--- /dev/null
+++ b/src/main/java/command/Command.java
@@ -0,0 +1,28 @@
+package duke.command;
+
+import duke.task.TaskList;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.exception.DukeException;
+
+/**
+ * Abstract Command class that contains execute() for
+ * interacting with TaskList, Ui and Storage objects based on input.
+ */
+public abstract class Command {
+ /**
+ * Interacts with TaskList, Ui and Storage objects based on input.
+ *
+ * @param tasks TaskList to add Task to.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage that stores the modified TaskList.
+ */
+ public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException;
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return Boolean to initiate exit of program.
+ */
+ public abstract boolean isExit();
+}
\ No newline at end of file
diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java
new file mode 100644
index 0000000000..d08b076a01
--- /dev/null
+++ b/src/main/java/command/DeleteCommand.java
@@ -0,0 +1,51 @@
+package duke.command;
+
+import duke.exception.DukeException;
+import duke.util.Parser;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+import duke.task.Task;
+
+/**
+ * Command containing method for deleting Task from TaskList.
+ */
+public class DeleteCommand extends Command {
+ private int itemId;
+
+ /**
+ * Constructor for DeleteCommand.
+ *
+ * @param itemId Id of item to be deleted.
+ */
+ public DeleteCommand(int itemId) {
+ this.itemId = itemId;
+ }
+
+ /**
+ * Deletes a Task from the TaskList.
+ *
+ * @param tasks TaskList to delete Task from.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage that stores the modified TaskList.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
+ try {
+ Task item = tasks.remove(this.itemId);
+ ui.printResponse("Noted. I've removed this task: \n "
+ + item.toString() + "\n"
+ + "Now you have " + tasks.size() + " tasks in the list.");
+ } catch (IndexOutOfBoundsException e) {
+ throw new DukeException("☹ OOPS!!! There is no item " + this.itemId + ".");
+ }
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return false so program does not exit.
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/DoneCommand.java b/src/main/java/command/DoneCommand.java
new file mode 100644
index 0000000000..6c004e1d67
--- /dev/null
+++ b/src/main/java/command/DoneCommand.java
@@ -0,0 +1,50 @@
+package duke.command;
+
+import duke.exception.DukeException;
+import duke.util.Parser;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+import duke.task.Task;
+
+/**
+ * Command containing method for marking Task from TaskList as done.
+ */
+public class DoneCommand extends Command {
+ private int itemId;
+
+ /**
+ * Constructor for DoneCommand.
+ *
+ * @param itemId Id of item to be marked done.
+ */
+ public DoneCommand(int itemId) {
+ this.itemId = itemId;
+ }
+
+ /**
+ * Marks a Task from the TaskList as done.
+ *
+ * @param tasks TaskList to delete Task from.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage that stores the modified TaskList.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
+ try {
+ tasks.markAsDone(this.itemId);
+ } catch (IndexOutOfBoundsException e) {
+ throw new DukeException("☹ OOPS!!! There is no item " + itemId + ".");
+ }
+ ui.printResponse("Nice! I've marked this task as done: \n "
+ + tasks.get(this.itemId).toString());
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return false so program does not exit.
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/ExitCommand.java b/src/main/java/command/ExitCommand.java
new file mode 100644
index 0000000000..d0260def77
--- /dev/null
+++ b/src/main/java/command/ExitCommand.java
@@ -0,0 +1,30 @@
+package duke.command;
+
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+
+/**
+ * Command containing method for exiting program.
+ */
+public class ExitCommand extends Command {
+ /**
+ * Exits program.
+ *
+ * @param tasks TaskList of program.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage of program.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) {
+ ui.printResponse("Bye. Hope to see you again soon!");
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return false so program does not exit.
+ */
+ public boolean isExit() {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/FindCommand.java b/src/main/java/command/FindCommand.java
new file mode 100644
index 0000000000..22f511394e
--- /dev/null
+++ b/src/main/java/command/FindCommand.java
@@ -0,0 +1,51 @@
+package duke.command;
+
+import duke.exception.DukeException;
+import duke.util.Parser;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+import duke.task.Task;
+
+/**
+ * Command containing method for finding Tasks in TaskList.
+ */
+public class FindCommand extends Command {
+ private String query;
+
+ /**
+ * Constructor for FindCommand.
+ *
+ * @param query Query to be matched.
+ */
+ public FindCommand(String query) {
+ this.query = query;
+ }
+
+ /**
+ * Finds Tasks from the TaskList that matches the query.
+ *
+ * @param tasks TaskList to find Tasks from.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage that stores the modified TaskList.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
+ TaskList tempList = new TaskList();
+ for (Task task : tasks) {
+ if (task.toString().contains(this.query)) {
+ tempList.addTask(task);
+ }
+ }
+ ui.printResponse("Here are the matching tasks in your list:\n"
+ + tempList.toString() + "\n");
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return false so program does not exit.
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/ListCommand.java b/src/main/java/command/ListCommand.java
new file mode 100644
index 0000000000..b52dd18adf
--- /dev/null
+++ b/src/main/java/command/ListCommand.java
@@ -0,0 +1,31 @@
+package duke.command;
+
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+
+/**
+ * Command containing method for listing Tasks in TaskList.
+ */
+public class ListCommand extends Command {
+ /**
+ * List Tasks in TaskList.
+ *
+ * @param tasks TaskList of program.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage of program.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) {
+ ui.printResponse("Here are the tasks in your list:\n"
+ + tasks.toString());
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return false so program does not exit.
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/command/SortCommand.java b/src/main/java/command/SortCommand.java
new file mode 100644
index 0000000000..880dfc16fe
--- /dev/null
+++ b/src/main/java/command/SortCommand.java
@@ -0,0 +1,46 @@
+package duke.command;
+
+import duke.exception.DukeException;
+import duke.util.Parser;
+import duke.util.Ui;
+import duke.util.Storage;
+import duke.task.TaskList;
+import duke.task.Task;
+
+/**
+ * Command containing method for finding Tasks in TaskList.
+ */
+public class SortCommand extends Command {
+ private String field;
+
+ /**
+ * Constructor for SortCommand.
+ *
+ * @param field Field to sort tasks by.
+ */
+ public SortCommand(String field) {
+ this.field = field;
+ }
+
+ /**
+ * Sorts Tasks in TaskList according to the specified field.
+ *
+ * @param tasks TaskList to sort Tasks.
+ * @param ui Ui for printing responses to the console.
+ * @param storage Storage that stores the modified TaskList.
+ */
+ public void execute(TaskList tasks, Ui ui, Storage storage) throws DukeException {
+ tasks.sort(field);
+ ui.printResponse("Here is the sorted list:\n"
+ + tasks.toString() + "\n");
+ }
+
+ /**
+ * Returns boolean to initiate exit of program.
+ *
+ * @return False so program does not exit.
+ */
+ public boolean isExit() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/data/duke.txt b/src/main/java/data/duke.txt
new file mode 100644
index 0000000000..b8a267bbf9
Binary files /dev/null and b/src/main/java/data/duke.txt differ
diff --git a/src/main/java/duke/DialogBox.class b/src/main/java/duke/DialogBox.class
new file mode 100644
index 0000000000..a1859a6f6e
Binary files /dev/null and b/src/main/java/duke/DialogBox.class differ
diff --git a/src/main/java/duke/Duke.class b/src/main/java/duke/Duke.class
new file mode 100644
index 0000000000..9a187ca99f
Binary files /dev/null and b/src/main/java/duke/Duke.class differ
diff --git a/src/main/java/duke/DukeLogic.class b/src/main/java/duke/DukeLogic.class
new file mode 100644
index 0000000000..2f7b350da5
Binary files /dev/null and b/src/main/java/duke/DukeLogic.class differ
diff --git a/src/main/java/duke/Launcher.class b/src/main/java/duke/Launcher.class
new file mode 100644
index 0000000000..72ecf69fdb
Binary files /dev/null and b/src/main/java/duke/Launcher.class differ
diff --git a/src/main/java/duke/Main.class b/src/main/java/duke/Main.class
new file mode 100644
index 0000000000..2d0b36aa38
Binary files /dev/null and b/src/main/java/duke/Main.class differ
diff --git a/src/main/java/duke/MainWindow.class b/src/main/java/duke/MainWindow.class
new file mode 100644
index 0000000000..b87fbbbc56
Binary files /dev/null and b/src/main/java/duke/MainWindow.class differ
diff --git a/src/main/java/duke/command/AddCommand.class b/src/main/java/duke/command/AddCommand.class
new file mode 100644
index 0000000000..409079f432
Binary files /dev/null and b/src/main/java/duke/command/AddCommand.class differ
diff --git a/src/main/java/duke/command/Command.class b/src/main/java/duke/command/Command.class
new file mode 100644
index 0000000000..e5fcc3e53f
Binary files /dev/null and b/src/main/java/duke/command/Command.class differ
diff --git a/src/main/java/duke/command/DeleteCommand.class b/src/main/java/duke/command/DeleteCommand.class
new file mode 100644
index 0000000000..565dc6dff3
Binary files /dev/null and b/src/main/java/duke/command/DeleteCommand.class differ
diff --git a/src/main/java/duke/command/DoneCommand.class b/src/main/java/duke/command/DoneCommand.class
new file mode 100644
index 0000000000..0e76f3984c
Binary files /dev/null and b/src/main/java/duke/command/DoneCommand.class differ
diff --git a/src/main/java/duke/command/ExitCommand.class b/src/main/java/duke/command/ExitCommand.class
new file mode 100644
index 0000000000..3d6cbcff94
Binary files /dev/null and b/src/main/java/duke/command/ExitCommand.class differ
diff --git a/src/main/java/duke/command/FindCommand.class b/src/main/java/duke/command/FindCommand.class
new file mode 100644
index 0000000000..61da9ee3ba
Binary files /dev/null and b/src/main/java/duke/command/FindCommand.class differ
diff --git a/src/main/java/duke/command/ListCommand.class b/src/main/java/duke/command/ListCommand.class
new file mode 100644
index 0000000000..448c2b0f09
Binary files /dev/null and b/src/main/java/duke/command/ListCommand.class differ
diff --git a/src/main/java/duke/command/SortCommand.class b/src/main/java/duke/command/SortCommand.class
new file mode 100644
index 0000000000..d69d7232ae
Binary files /dev/null and b/src/main/java/duke/command/SortCommand.class differ
diff --git a/src/main/java/duke/exception/DukeException.class b/src/main/java/duke/exception/DukeException.class
new file mode 100644
index 0000000000..98e508329b
Binary files /dev/null and b/src/main/java/duke/exception/DukeException.class differ
diff --git a/src/main/java/duke/task/Deadline.class b/src/main/java/duke/task/Deadline.class
new file mode 100644
index 0000000000..669acdcb33
Binary files /dev/null and b/src/main/java/duke/task/Deadline.class differ
diff --git a/src/main/java/duke/task/Event.class b/src/main/java/duke/task/Event.class
new file mode 100644
index 0000000000..8a4d32babe
Binary files /dev/null and b/src/main/java/duke/task/Event.class differ
diff --git a/src/main/java/duke/task/Task.class b/src/main/java/duke/task/Task.class
new file mode 100644
index 0000000000..d686c4ef4e
Binary files /dev/null and b/src/main/java/duke/task/Task.class differ
diff --git a/src/main/java/duke/task/TaskList.class b/src/main/java/duke/task/TaskList.class
new file mode 100644
index 0000000000..2e95f2d595
Binary files /dev/null and b/src/main/java/duke/task/TaskList.class differ
diff --git a/src/main/java/duke/task/Todo.class b/src/main/java/duke/task/Todo.class
new file mode 100644
index 0000000000..bfd924ed94
Binary files /dev/null and b/src/main/java/duke/task/Todo.class differ
diff --git a/src/main/java/duke/util/Parser.class b/src/main/java/duke/util/Parser.class
new file mode 100644
index 0000000000..e04bdcf2f9
Binary files /dev/null and b/src/main/java/duke/util/Parser.class differ
diff --git a/src/main/java/duke/util/Storage.class b/src/main/java/duke/util/Storage.class
new file mode 100644
index 0000000000..d6b5296468
Binary files /dev/null and b/src/main/java/duke/util/Storage.class differ
diff --git a/src/main/java/duke/util/Ui.class b/src/main/java/duke/util/Ui.class
new file mode 100644
index 0000000000..f6dffc2adc
Binary files /dev/null and b/src/main/java/duke/util/Ui.class differ
diff --git a/src/main/java/exception/DukeException.java b/src/main/java/exception/DukeException.java
new file mode 100644
index 0000000000..daa62a2058
--- /dev/null
+++ b/src/main/java/exception/DukeException.java
@@ -0,0 +1,15 @@
+package duke.exception;
+
+/**
+ * Exception class for Duke.
+ */
+public class DukeException extends Exception {
+ /**
+ * Constructor method for DukeException.
+ *
+ * @param errorMessage Error message to be displayed for the error
+ */
+ public DukeException(String errorMessage) {
+ super(errorMessage);
+ }
+}
diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java
new file mode 100644
index 0000000000..b1a438b698
--- /dev/null
+++ b/src/main/java/task/Deadline.java
@@ -0,0 +1,30 @@
+package duke.task;
+
+import java.util.Date;
+
+/**
+ * Task containing information about a deadline.
+ */
+public class Deadline extends Task {
+ /**
+ * Constructor for Deadline object.
+ *
+ * @param description Description of deadline.
+ * @param date Date of deadline.
+ */
+ public Deadline(String description, Date date) {
+ super("D", description, date);
+ }
+
+ /**
+ * Returns String containing information about the deadline.
+ *
+ * @return String containing status, description and date of deadline.
+ */
+ public String toString() {
+ return String.format("[%s][%s] %s (by: %s)", this.type,
+ this.getStatusIcon(),
+ this.description,
+ this.date.toString());
+ }
+}
diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java
new file mode 100644
index 0000000000..e6cbe38de5
--- /dev/null
+++ b/src/main/java/task/Event.java
@@ -0,0 +1,30 @@
+package duke.task;
+
+import java.util.Date;
+
+/**
+ * Task containing information about an event.
+ */
+public class Event extends Task {
+ /**
+ * Constructor for Event object.
+ *
+ * @param description Description of event.
+ * @param date Date of event.
+ */
+ public Event(String description, Date date) {
+ super("E", description, date);
+ }
+
+ /**
+ * Returns String containing information about the event.
+ *
+ * @return String containing status, description and date of deadline.
+ */
+ public String toString() {
+ return String.format("[%s][%s] %s (at: %s)", this.type,
+ this.getStatusIcon(),
+ this.description,
+ this.date.toString());
+ }
+}
diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java
new file mode 100644
index 0000000000..f6e2382f78
--- /dev/null
+++ b/src/main/java/task/Task.java
@@ -0,0 +1,103 @@
+package duke.task;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Task class for storing information about a task.
+ */
+public class Task implements Serializable {
+ protected String type;
+ protected String description;
+ protected Date date;
+ protected boolean isDone;
+
+ /**
+ * Constructor for Task object.
+ *
+ * @param type Type of task.
+ * @param description Description of task.
+ * @param date Date of task.
+ */
+ public Task(String type, String description, Date date) {
+ this.type = type;
+ this.description = description;
+ this.date = date;
+ this.isDone = false;
+ }
+
+ /**
+ * Returns String containing type of task.
+ *
+ * @return String of type.
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * Returns String containing description of task.
+ *
+ * @return String containing description.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Returns Date containing date of task.
+ *
+ * @return Date containing date.
+ */
+ public Date getDate() {
+ return this.date;
+ }
+
+ /**
+ * Returns String containing status of task.
+ *
+ * @return String containing status.
+ */
+ public String getStatusIcon() {
+ return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols
+ }
+
+ /**
+ * Sets status of task as done.
+ */
+ public void markAsDone() {
+ this.isDone = true;
+ }
+
+ /**
+ * Sets status of task as undone.
+ */
+ public void markAsUnDone() {
+ this.isDone = false;
+ }
+
+ /**
+ * Returns true if Tasks have the same values in all fields, else false.
+ *
+ * @param task Task to be compared to this Task.
+ * @return True if Tasks are the same.
+ */
+ public boolean equals(Task task) {
+ return this.type.equals(task.type)
+ && this.description.equals(task.description)
+ && this.date.equals(task.date);
+ }
+
+ /**
+ * Returns String containing information about the task.
+ *
+ * @return String containing status, description and date of task.
+ */
+ @Override
+ public String toString() {
+ return String.format("[%s][%s] %s %s", this.type,
+ this.getStatusIcon(),
+ this.description,
+ this.date.toString());
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/task/TaskList.java b/src/main/java/task/TaskList.java
new file mode 100644
index 0000000000..7705eeeb07
--- /dev/null
+++ b/src/main/java/task/TaskList.java
@@ -0,0 +1,114 @@
+package duke.task;
+
+import duke.exception.DukeException;
+import duke.task.Task;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * TaskList class contains Tasks to be done.
+ */
+public class TaskList extends ArrayList implements Serializable {
+ /**
+ * Adds Task to TaskList.
+ *
+ * @param task Task to be added to TaskList.
+ * @return Boolean if Task is successfully added.
+ */
+ public boolean addTask(Task task) throws DukeException {
+ if (this.hasDuplicates(task)) {
+ throw new DukeException("☹ OOPS!!! Task already exists in the list.");
+ }
+ return this.add(task);
+ }
+
+ /**
+ * Returns Task of the specified id.
+ *
+ * @param itemId Id of the Task.
+ * @return Task of the specified itemId.
+ */
+ public Task get(int itemId) {
+ return super.get(itemId - 1);
+ }
+
+ /**
+ * Returns Task that has been removed from TaskList.
+ *
+ * @param itemId Id of the Task to be removed.
+ * @return Task which has been removed from TaskList.
+ */
+ @Override
+ public Task remove(int itemId) {
+ return super.remove(itemId - 1);
+ }
+
+ /**
+ * Marks the Task of the specified id as done.
+ *
+ * @param itemId Id of the Task to be marked as done.
+ */
+ public void markAsDone(int itemId) {
+ super.get(itemId - 1).markAsDone();
+ }
+
+ /**
+ * Sorts Tasks in TaskList by field specified.
+ *
+ * @param field Field to sort Tasks by.
+ */
+ public void sort(String field) throws DukeException {
+ switch (field) {
+ case "date":
+ Collections.sort(this,
+ (task1, task2) -> task1.getDate().compareTo(task2.getDate()));
+ break;
+ case "description":
+ Collections.sort(this,
+ (task1, task2) -> task1.getDescription().compareTo(task2.getDescription()));
+ break;
+ case "type":
+ Collections.sort(this,
+ (task1, task2) -> task1.getType().compareTo(task2.getType()));
+ break;
+ case "done":
+ Collections.sort(this,
+ (task1, task2) -> task1.getStatusIcon().compareTo(task2.getStatusIcon()));
+ break;
+ default:
+ throw new DukeException("☹ OOPS!!! Field not found to sort.");
+ }
+ }
+
+ /**
+ * Returns true if there are duplicate Tasks in TaskList, else false.
+ *
+ * @param task1 Task to be checked against.
+ * @return True if there are duplicate Tasks, else false.
+ */
+ public boolean hasDuplicates(Task task1) {
+ for (Task task2 : this) {
+ if (task1.equals(task2)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns String of Tasks contained in TaskList.
+ *
+ * @return String of Tasks contained in TaskList.
+ */
+ public String toString() {
+ StringBuffer listBuffer = new StringBuffer();
+ int len = this.size();
+ for (int i = 1; i <= len; i++) {
+ listBuffer.append(i + "."
+ + this.get(i).toString()
+ + "\n");
+ }
+ return listBuffer.toString();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/task/Todo.java b/src/main/java/task/Todo.java
new file mode 100644
index 0000000000..581b5c3d76
--- /dev/null
+++ b/src/main/java/task/Todo.java
@@ -0,0 +1,28 @@
+package duke.task;
+
+import java.util.Date;
+
+/**
+ * Task containing information about a todo.
+ */
+public class Todo extends Task {
+ /**
+ * Constructor for Todo object.
+ *
+ * @param description Description of todo.
+ */
+ public Todo(String description) {
+ super("T", description, new Date());
+ }
+
+ /**
+ * Returns String containing information about the todo.
+ *
+ * @return String containing status, description and date of todo.
+ */
+ public String toString() {
+ return String.format("[%s][%s] %s", this.type,
+ this.getStatusIcon(),
+ this.description);
+ }
+}
diff --git a/src/main/java/util/Parser.java b/src/main/java/util/Parser.java
new file mode 100644
index 0000000000..100ab4bc42
--- /dev/null
+++ b/src/main/java/util/Parser.java
@@ -0,0 +1,207 @@
+package duke.util;
+
+import duke.command.Command;
+import duke.command.AddCommand;
+import duke.command.DeleteCommand;
+import duke.command.DoneCommand;
+import duke.command.ExitCommand;
+import duke.command.FindCommand;
+import duke.command.ListCommand;
+import duke.command.SortCommand;
+
+import duke.task.Task;
+import duke.task.Todo;
+import duke.task.Deadline;
+import duke.task.Event;
+
+import duke.exception.DukeException;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.function.Function;
+
+/**
+ * Parses input entered by user.
+ */
+public class Parser {
+ protected static SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy HHmm");
+
+ /**
+ * Returns the command as specified by the input.
+ * If input cannot be parsed, throws DukeException.
+ *
+ * @param input Input entered by user.
+ * @return Command object specified by input.
+ * @throws DukeException If input cannot be parsed.
+ */
+ public static Command parse(String input) throws DukeException {
+ if (input.equals("bye")) {
+ return new ExitCommand();
+ }
+ if (input.equals("list")) {
+ return new ListCommand();
+ }
+
+ String keyword = input.split(" ")[0];
+ switch (keyword) {
+ case "done":
+ return parseDone(input);
+ case "delete":
+ return parseDelete(input);
+ case "todo":
+ return parseTask(input);
+ case "deadline":
+ return parseTask(input);
+ case "event":
+ return parseTask(input);
+ case "find":
+ return parseFind(input);
+ case "sort":
+ return parseSort(input);
+ default:
+ throw new DukeException("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
+ }
+ }
+
+ /**
+ * Returns the itemId for the task to be marked done.
+ * If input cannot be parsed, throws DukeException.
+ *
+ * @param input Input entered by user.
+ * @return DoneCommand to execute done action.
+ * @throws DukeException If input has incorrect format.
+ */
+ public static DoneCommand parseDone(String input) throws DukeException {
+ String[] words = input.split(" ");
+ int itemId;
+ try {
+ assert (words.length == 2);
+ String command = words[0];
+ itemId = Integer.parseInt(words[1]);
+ } catch (AssertionError | NumberFormatException | IndexOutOfBoundsException e) {
+ throw new DukeException("☹ OOPS!!! Incorrect format for done command. Format: `done [ITEMID]`.");
+ }
+
+ return new DoneCommand(itemId);
+ }
+
+ /**
+ * Returns the itemId for the task to be deleted.
+ * If input cannot be parsed, throws DukeException.
+ *
+ * @param input Input entered by user.
+ * @return DeleteCommand to execute deletion of Task.
+ * @throws DukeException If input has incorrect format.
+ */
+ public static DeleteCommand parseDelete(String input) throws DukeException {
+ String[] words = input.split(" ");
+ int itemId;
+ try {
+ assert (words.length == 2);
+ String command = words[0];
+ itemId = Integer.parseInt(words[1]);
+ } catch (AssertionError | NumberFormatException | IndexOutOfBoundsException e) {
+ throw new DukeException("☹ OOPS!!! Incorrect format for delete command. Format: `delete [ITEMID]`.");
+ }
+
+ return new DeleteCommand(itemId);
+ }
+
+ /**
+ * Returns the Task to be added to the TaskList.
+ * If input cannot be parsed, throws DukeException.
+ *
+ * @param input Input entered by user.
+ * @return AddCommand to execute addition of Task.
+ * @throws DukeException If input has incorrect format.
+ */
+ public static AddCommand parseTask(String input) throws DukeException {
+ String[] words = input.split(" ");
+ String type = words[0];
+
+ String info = input.substring(type.length()).trim();
+
+ Task task = null;
+ switch (type) {
+ case "todo":
+ String description = info;
+ if (description.equals("")) {
+ throw new DukeException("☹ OOPS!!! The description of a todo cannot be empty.");
+ }
+
+ return new AddCommand(new Todo(description));
+ case "deadline":
+ String[] args = info.split("/by");
+ if (args.length != 2) {
+ throw new DukeException("☹ OOPS!!! A deadline must include a description and date.");
+ }
+
+ description = args[0].trim();
+ if (description.equals("")) {
+ throw new DukeException("☹ OOPS!!! The description of a deadline cannot be empty.");
+ }
+
+ Date date;
+ try {
+ date = dateFormatter.parse(args[1].trim());
+ } catch (ParseException e) {
+ throw new DukeException("☹ OOPS!!! Incorrect date format.");
+ }
+
+ return new AddCommand(new Deadline(description, date));
+ case "event":
+ args = info.split("/at");
+ if (args.length != 2) {
+ throw new DukeException("☹ OOPS!!! An event must include a description and date.");
+ }
+
+ description = args[0].trim();
+ if (description.equals("")) {
+ throw new DukeException("☹ OOPS!!! The description of an event cannot be empty.");
+ }
+
+ try {
+ date = dateFormatter.parse(args[1].trim());
+ } catch (ParseException e) {
+ throw new DukeException("☹ OOPS!!! Incorrect date format. Format: `[MONTH]/[DAY]/[YEAR] [HOUR][MIN]`.");
+ }
+
+ return new AddCommand(new Event(description, date));
+ default:
+ throw new DukeException("☹ OOPS!!! Invalid format for task command.");
+ }
+ }
+
+ /**
+ * Returns query to match to Tasks.
+ *
+ * @param input Input entered by user.
+ * @return FindCommand to execute find.
+ */
+ public static FindCommand parseFind(String input) throws DukeException {
+ String query;
+ try {
+ query = input.substring("find ".length()).trim();
+ } catch (IndexOutOfBoundsException e) {
+ throw new DukeException("☹ OOPS!!! Incorrect format for find command. Format: `find [QUERY]`.");
+ }
+ return new FindCommand(query);
+ }
+
+ /**
+ * Returns field to sort Tasks by.
+ *
+ * @param input Input entered by user.
+ * @return SortCommand to execute sort.
+ */
+ public static SortCommand parseSort(String input) throws DukeException {
+ String field;
+ try {
+ field = input.substring("sort".length()).trim();
+ } catch (IndexOutOfBoundsException e) {
+ throw new DukeException("☹ OOPS!!! Incorrect format for sort command. Format: `sort [FIELD]`.");
+ }
+ return new SortCommand(field);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/util/Storage.java b/src/main/java/util/Storage.java
new file mode 100644
index 0000000000..0631999446
--- /dev/null
+++ b/src/main/java/util/Storage.java
@@ -0,0 +1,60 @@
+package duke.util;
+
+import duke.task.TaskList;
+import duke.exception.DukeException;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Storage class of Duke.
+ * Handles saving of TaskList data.
+ */
+public class Storage {
+ protected String filePath;
+
+ /**
+ * Constructor of Storage.
+ *
+ * @param filePath Specifies where save data is to be stored and loaded from.
+ */
+ public Storage(String filePath) {
+ this.filePath = filePath;
+ }
+
+ /**
+ * Saves TaskList data to file specified in filePath.
+ *
+ * @param list TaskList which data is to be saved.
+ */
+ public void save(TaskList list) {
+ try {
+ FileOutputStream fout = new FileOutputStream(this.filePath);
+ ObjectOutputStream out = new ObjectOutputStream(fout);
+ out.writeObject(list);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ /**
+ * Returns TaskList constructed from loaded data from filePath.
+ *
+ * @return TaskList constructed from loaded data.
+ */
+ public TaskList load() throws DukeException {
+ TaskList list = new TaskList();
+ try {
+ ObjectInputStream in = new ObjectInputStream(new FileInputStream(this.filePath));
+ list = (TaskList) in.readObject();
+ in.close();
+ } catch (Exception e) {
+ throw new DukeException("Save data not found.");
+ }
+
+ return list;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/util/Ui.java b/src/main/java/util/Ui.java
new file mode 100644
index 0000000000..b8d89c96bc
--- /dev/null
+++ b/src/main/java/util/Ui.java
@@ -0,0 +1,78 @@
+package duke.util;
+
+import java.util.Scanner;
+
+/**
+ * Ui class that handles output of Duke to the console.
+ */
+public class Ui {
+ public String buffer;
+
+ String format(String output) {
+ return indent(output) + "\n";
+ }
+
+ String indent(String output) {
+ StringBuffer stringBuffer = new StringBuffer();
+ Scanner scanner = new Scanner(output);
+ while (scanner.hasNext()) {
+ String temp = scanner.nextLine();
+ stringBuffer.append(" " + temp + "\n");
+ }
+ scanner.close();
+ return stringBuffer.toString();
+ }
+
+ /**
+ * Prints output of Duke.
+ */
+ public void printResponse(String output) {
+ this.buffer = format(output);
+ System.out.println(this.buffer);
+ }
+
+ public String getOutput() {
+ return this.buffer;
+ }
+
+ /**
+ * Reads input of user from the console.
+ *
+ * @return String containing input of user.
+ */
+ public String readCommand() {
+ // Unable to close scanner - will trigger NullException error on scanner.nextLine()
+ Scanner scanner = new Scanner(System.in);
+ String fullCommand = scanner.nextLine();
+ return fullCommand;
+ }
+
+ /**
+ * Shows welcome message of Duke.
+ */
+ public void showWelcome() {
+ String logo = " ____ _ \n"
+ + "| _ \\ _ _| | _____ \n"
+ + "| | | | | | | |/ / _ \\\n"
+ + "| |_| | |_| | < __/\n"
+ + "|____/ \\__,_|_|\\_\\___|\n";
+ this.printResponse("Hello from\n"
+ + logo
+ + "Hello! I'm Duke\n"
+ + "What can I do for you?");
+ }
+
+ /**
+ * Shows error message of Duke.
+ */
+ public void showError(String message) {
+ this.printResponse(message);
+ }
+
+ /**
+ * Shows error if save data is not loaded.
+ */
+ public void showLoadingError() {
+ this.printResponse("☹ OOPS!!! No tasks saved.");
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/images/DaDuke.png b/src/main/resources/images/DaDuke.png
new file mode 100644
index 0000000000..d893658717
Binary files /dev/null and b/src/main/resources/images/DaDuke.png differ
diff --git a/src/main/resources/images/DaUser.png b/src/main/resources/images/DaUser.png
new file mode 100644
index 0000000000..3c82f45461
Binary files /dev/null and b/src/main/resources/images/DaUser.png differ
diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml
new file mode 100644
index 0000000000..e2b59b6e48
--- /dev/null
+++ b/src/main/resources/view/DialogBox.fxml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
new file mode 100644
index 0000000000..3add5bc787
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/test/java/duke/ParserTest.java b/src/test/java/duke/ParserTest.java
new file mode 100644
index 0000000000..48a07d4585
--- /dev/null
+++ b/src/test/java/duke/ParserTest.java
@@ -0,0 +1,13 @@
+import duke.util.Parser;
+import duke.exception.DukeException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class ParserTest {
+ @Test
+ void parserErrorTest() {
+ assertThrows(DukeException.class, () -> Parser.parse("This is input which is invalid."));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/duke/TaskListTest.java b/src/test/java/duke/TaskListTest.java
new file mode 100644
index 0000000000..5f7726e7e2
--- /dev/null
+++ b/src/test/java/duke/TaskListTest.java
@@ -0,0 +1,25 @@
+import duke.task.TaskList;
+import duke.task.Todo;
+import duke.exception.DukeException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class TaskListTest {
+ @Test
+ void addTaskTest() throws DukeException {
+ TaskList taskList = new TaskList();
+ taskList.addTask(new Todo("description"));
+ assertEquals(1, taskList.size());
+ taskList.remove(1);
+ }
+
+ @Test
+ void deleteTaskTest() throws DukeException {
+ TaskList taskList = new TaskList();
+ taskList.addTask(new Todo("description"));
+ taskList.remove(1);
+ assertEquals(0, taskList.size());
+ }
+}
\ No newline at end of file