diff --git a/README.md b/README.md
index 84755485a7..e9c50442d6 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Setting up
-**Prerequisites**
+**Prerequisites**
* JDK 11
* Recommended: IntelliJ IDE
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000000..2f7efbeab5
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-minimal
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..9e84d3e8cd
--- /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'
+}
+
+group 'seedu.duke'
+version '0.1.0'
+
+repositories {
+ mavenCentral()
+}
+
+shadowJar {
+ archiveBaseName = "duke"
+ archiveVersion = "0.2.1"
+ archiveClassifier = null
+ archiveAppendix = null
+}
+
+application {
+ // Change this to your main class.
+ mainClassName = "Launcher"
+}
+
+checkstyle {
+ toolVersion = '8.23'
+}
+
+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.0'
+}
+
+test {
+ useJUnitPlatform()
+}
+
+run {
+ standardInput = System.in
+}
\ 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/docs/README.md b/docs/README.md
index fd44069597..87b83b0018 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -2,19 +2,140 @@
## Features
-### Feature 1
-Description of feature.
+### Feature 1: "Create Tasks"
+Able to create tasks to be added to a task list. Supported tasks are TODO, DEADLINE and EVENT tasks.
+
+## Usage - a (TODO)
+
+### `todo [name]` - Creates a TODO Task with a specified name.
+
+Example of usage:
+
+`todo buy groceries`
+
+Expected outcome:
+
+`Got it. I've added this task:
+ [T][✗] buy groceries
+Now you have 1 tasks in the list.`
+
+## Usage - b (DEADLINE)
+
+### `deadline [name] [date]` - Creates a DEADLINE task with a specified name and date.
+
+Example of usage:
+
+`deadline groceries expire /by 11/11/2019 1800`
+
+date of the format: '/by dd/MM/yyyy HHmm'
+
+Expected outcome:
+
+`Got it. I've added this task:
+ [D][✗] groceries expire (by 11 Nov 2019, 0600PM)
+ Now you have 2 tasks in the list.`
+
+## Usage - c (EVENT)
+
+### `event [name] [date]` - Creates a EVENT task with a specified name and date.
+
+Example of usage:
+
+`event cook groceries /at 11/11/2019 1800`
+
+date of the format: '/at dd/MM/yyyy HHmm'
+
+Expected outcome:
+
+`Got it. I've added this task:
+ [E][✗] cook groceries (by 11 Nov 2019, 0600PM)
+ Now you have 3 tasks in the list.`
+
+### Feature 2: "List Tasks"
+Lists out all the current tasks in the task list.
## Usage
-### `Keyword` - Describe action
+### `list` - Lists out all the tasks in order of addition to the list.
+
+Example of usage:
+
+`list`
+
+Expected outcome:
+
+`1. [T][✗] buy groceries
+2. [D][✗] groceries expire (by 11 Nov 2019, 0600PM)
+3. [E][✗] cook groceries (by 11 Nov 2019, 0600PM)`
+
+
+
+### Feature 3: "Mark a Task as done"
+Marks a task in the task list as DONE.
+
+## Usage
+
+### `done [integer]` - Marks the task in the task list with the specified index as done (index is 1-based).
+
+Example of usage:
+
+`done 1`
+
+Expected outcome:
+
+`Nice! I've marked this task as done:
+ [T][✓] buy groceries`
+
+### Feature 4: "Delete a Task"
+Deletes a task from the task list (regardless of whether the task is done).
+
+## Usage
+
+### `delete [integer]` - Deletes the task in the task list with the specified index(index is 1-based).
Describe action and its outcome.
Example of usage:
-`keyword (optional arguments)`
+`delete 1`
+
+Expected outcome:
+
+` Noted. I've removed this task:
+ [T][✓] buy groceries
+ Now you have 2 tasks in the list.`
+
+### Feature 5: "Find a task"
+Finds a task in the task list by searching for a keyword.
+
+## Usage
+
+### `find [keyword]` - Finds a task in the task list by searching for a keyword.
+
+Example of usage:
+
+`find groceries`
+
+Expected outcome:
+
+` Here are the matching tasks in your list:
+ 1.[D][✗] groceries expire (by 11 Nov 2019, 0600PM)
+ 2.[E][✗] cook groceries (by 11 Nov 2019, 0600PM)
+`
+
+### Feature 6: "Undo"
+Undos the creation of the last task in the task list.
+
+## Usage
+
+### `Undo` - Undos the creation of the last task in the task list.
+
+Example of usage:
+
+`undo`
Expected outcome:
-`outcome`
+`The last created task has been deleted:
+[E][✗] cook groceries (by 11 Nov 2019, 0600PM)
+`
\ No newline at end of file
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..d418dc5d7d
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..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..f86040c7fa
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Sep 11 03:55:13 SGT 2019
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
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..339242ede2
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,85 @@
+@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"
+set GRADLE_OPTS="-Dfile.encodingutf-8"
+
+@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..2e16b5552c
--- /dev/null
+++ b/src/main/java/DialogBox.java
@@ -0,0 +1,67 @@
+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(Main.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);
+ }
+
+ /**
+ * Returns the DialogBox for Duke, which is flipped from the User's DialogBox.
+ *
+ * @param text String to be returned as Duke's reply to User input.
+ * @param img Duke's image.
+ * @return Duke's DialogBox.
+ */
+ 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..0b0d9f4d0e 100644
--- a/src/main/java/Duke.java
+++ b/src/main/java/Duke.java
@@ -1,10 +1,63 @@
+import javafx.fxml.FXML;
+
+import command.Command;
+import main.Parser;
+import main.Storage;
+import main.TaskList;
+import task.Task;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * Duke runs as the main and this is where all the work is initialised at.
+ */
public class Duke {
- public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
+ private Storage storage;
+ private TaskList taskList;
+
+ /**
+ * Constructs an instance of Duke. Also instantiates an instance of Storage and TaskList for this instance of Duke.
+ */
+ public Duke() {
+ storage = new Storage();
+ ArrayList list = storage.readFromFile();
+ this.taskList = new TaskList(list);
+ }
+
+ /**
+ * Handles the parsing of inputs and execution of parsed commands.
+ *
+ * As long as a ByeCommand is not parsed, Duke will continue parsing for more commands. If a ByeCommand is
+ * parsed, the while loop is terminated and Duke terminates.
+ *
+ * @throws IOException When the Parser f
+ */
+ private String run(String command) throws IOException {
+ Parser parser = new Parser();
+ //Scanner sc = new Scanner(System.in);
+
+ Command c = parser.parse(command);
+ return c.execute(taskList, storage);
+ }
+
+ /**
+ * Sends the user input to Duke backend to be processed.
+ *
+ * @param input String input from the user.
+ * @param duke This instance of Duke.
+ *
+ * @return Returns a string to be shown to the user.
+ */
+ @FXML
+ public String getResponse(String input, Duke duke) {
+ String toReturn = "";
+ try {
+ toReturn = duke.run(input);
+ } catch (IOException io) {
+ System.err.println(io);
+ }
+
+ return toReturn;
}
}
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..fe4d706e29
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,33 @@
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+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..51197999ed
--- /dev/null
+++ b/src/main/java/MainWindow.java
@@ -0,0 +1,59 @@
+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;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 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;
+ }
+
+ /**
+ * 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, duke);
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, userImage),
+ DialogBox.getDukeDialog(response, dukeImage)
+ );
+ userInput.clear();
+
+ if (input.equals("bye")) {
+ CompletableFuture.delayedExecutor(1, TimeUnit.SECONDS).execute(() -> {
+ System.exit(0);
+ });
+ }
+ }
+}
diff --git a/src/main/java/command/ByeCommand.java b/src/main/java/command/ByeCommand.java
new file mode 100644
index 0000000000..c114bb3cda
--- /dev/null
+++ b/src/main/java/command/ByeCommand.java
@@ -0,0 +1,24 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+
+/**
+ * A Command to handle "bye" inputs resulting in a termination of the Duke program.
+ */
+public class ByeCommand implements Command {
+ public ByeCommand() {
+
+ }
+
+ /**
+ * Prints the bye message via the UI method, UI.bye().
+ *
+ * @param taskList The TaskList used to store the Tasks for this instance of Duke (not used in this method).
+ * @param storage The Storage used to store the Tasks on the hard disk (not used in this method).
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ return UI.bye();
+ }
+}
diff --git a/src/main/java/command/Command.java b/src/main/java/command/Command.java
new file mode 100644
index 0000000000..c08d7497fc
--- /dev/null
+++ b/src/main/java/command/Command.java
@@ -0,0 +1,15 @@
+package command;
+
+import java.io.IOException;
+
+import main.Storage;
+import main.TaskList;
+
+/**
+ * An interface to be implemented by all the Command type objects.
+ *
+ * All Commands must implement an execute method, which will be accessed by the Duke.run() method.
+ */
+public interface Command {
+ String execute(TaskList tl, Storage st) throws IOException;
+}
diff --git a/src/main/java/command/DeadlineCommand.java b/src/main/java/command/DeadlineCommand.java
new file mode 100644
index 0000000000..7ce763cb87
--- /dev/null
+++ b/src/main/java/command/DeadlineCommand.java
@@ -0,0 +1,41 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Deadline;
+import task.Task;
+
+
+/**
+ * A Command to create an instance of a Deadline Task. This will add the Deadline Task to the TaskList and the Storage
+ * file.
+ */
+public class DeadlineCommand implements Command {
+ private String deadlineName;
+ private String date;
+
+ public DeadlineCommand(String deadlineName, String date) {
+ this.deadlineName = deadlineName;
+ this.date = date;
+ }
+
+ /**
+ * Executes the Deadline command which creates a Deadline Task.
+ *
+ * Taking the TaskList and Storage object of the main Duke class as arguments, this command will create a
+ * new Deadline Task which will then be added to the TaskList and Storage objects. The UI will also be used to
+ * print a newTask message into the console.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ Task deadline = new Deadline(deadlineName, date);
+
+ taskList.addTaskList(deadline);
+ storage.writeToFile(taskList.getTaskList());
+
+ return UI.newTask(taskList.getTaskList());
+ }
+}
diff --git a/src/main/java/command/DeleteCommand.java b/src/main/java/command/DeleteCommand.java
new file mode 100644
index 0000000000..652394ba09
--- /dev/null
+++ b/src/main/java/command/DeleteCommand.java
@@ -0,0 +1,50 @@
+package command;
+
+import java.util.ArrayList;
+
+import exception.DeleteException;
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Task;
+
+/**
+ * A Command to remove a Task from the TaskList and Storage.
+ */
+public class DeleteCommand implements Command {
+ /**
+ * Indicates which element of the TaskList needs to be deleted.
+ */
+ private int taskNum;
+
+ public DeleteCommand(int taskNum) {
+ this.taskNum = taskNum;
+ }
+
+ /**
+ * Deletes a specific Task from the TaskList and Storage as indicated by the taskNum attribute.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ String toReturn = "";
+
+ try {
+ ArrayList list = taskList.getTaskList();
+ if (taskNum > list.size() || taskNum <= 0) {
+ throw new DeleteException();
+ }
+ Task task = list.remove(taskNum - 1);
+ int listSize = list.size();
+
+ storage.writeToFile(list);
+
+ return UI.removedTask(task, listSize);
+ } catch (DeleteException delExp) {
+ System.err.println(delExp);
+ }
+
+ return toReturn;
+ }
+}
diff --git a/src/main/java/command/DoneCommand.java b/src/main/java/command/DoneCommand.java
new file mode 100644
index 0000000000..2684b7d285
--- /dev/null
+++ b/src/main/java/command/DoneCommand.java
@@ -0,0 +1,38 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Task;
+
+import java.util.ArrayList;
+
+/**
+ * A Command indicate that a Task from the TaskList and Storage has been completed.
+ */
+public class DoneCommand implements Command {
+ /**
+ * Indicates which element of the TaskList has been completed.
+ */
+ private int taskNum;
+
+ public DoneCommand(int taskNum) {
+ this.taskNum = taskNum;
+ }
+
+ /**
+ * Marks a specific Task from the TaskList and Storage as indicated by the taskNum attribute as completed.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ ArrayList list = taskList.getTaskList();
+
+ Task currTask = list.get(taskNum);
+ currTask.setDone();
+ storage.writeToFile(list);
+
+ return UI.done(currTask);
+ }
+}
diff --git a/src/main/java/command/EventCommand.java b/src/main/java/command/EventCommand.java
new file mode 100644
index 0000000000..04e4f533bf
--- /dev/null
+++ b/src/main/java/command/EventCommand.java
@@ -0,0 +1,43 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Event;
+import task.Task;
+
+import java.util.ArrayList;
+
+/**
+ * A Command to create an instance of a Event Task. This will add the Event Task to the TaskList and the Storage file.
+ */
+public class EventCommand implements Command {
+ private String eventName;
+ private String date;
+
+ public EventCommand(String eventName, String date) {
+ this.eventName = eventName;
+ this.date = date;
+ }
+
+ /**
+ * Executes the Event command which creates a Event Task.
+ *
+ * Taking the TaskList and Storage object of the main Duke class as arguments, this command will create a
+ * new Deadline Task which will then be added to the TaskList and Storage objects. The UI will also be used to
+ * print a newTask message into the console.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ ArrayList list = taskList.getTaskList();
+
+ Task event = new Event(eventName, date);
+
+ taskList.addTaskList(event);
+ storage.writeToFile(list);
+
+ return UI.newTask(list);
+ }
+}
diff --git a/src/main/java/command/FindCommand.java b/src/main/java/command/FindCommand.java
new file mode 100644
index 0000000000..2b87beacfd
--- /dev/null
+++ b/src/main/java/command/FindCommand.java
@@ -0,0 +1,37 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Task;
+
+public class FindCommand implements Command {
+ private String searchTerm;
+
+ public FindCommand(String searchTerm) {
+ this.searchTerm = searchTerm;
+ }
+
+ @Override
+ public String execute(TaskList tl, Storage st) {
+ StringBuilder toReturn = new StringBuilder(UI.findStart());
+ int counter = 1;
+
+ for (Task task : tl.getTaskList()) {
+ String[] taskNameComponents = task.getName().split(" ");
+
+ for (String nameComponent : taskNameComponents) {
+ if (nameComponent.equalsIgnoreCase(searchTerm)) {
+ toReturn.append(" ");
+ toReturn.append(counter);
+ toReturn.append(".");
+ toReturn.append(task);
+ toReturn.append("\n");
+ counter++;
+ break;
+ }
+ }
+ }
+ return toReturn.toString();
+ }
+}
diff --git a/src/main/java/command/ListCommand.java b/src/main/java/command/ListCommand.java
new file mode 100644
index 0000000000..f8eff4faa2
--- /dev/null
+++ b/src/main/java/command/ListCommand.java
@@ -0,0 +1,36 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import task.Task;
+
+import java.util.ArrayList;
+
+/**
+ * A Command to print a list of all the Tasks in the TaskList.
+ */
+public class ListCommand implements Command {
+ public ListCommand() {
+
+ }
+
+ /**
+ * Prints into the console all the Tasks in the TaskList.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ StringBuilder toReturn = new StringBuilder();
+ ArrayList list = taskList.getTaskList();
+ for (int i = 0; i < list.size(); i++) {
+ if (list.get(i) != null) {
+ toReturn.append(i + 1);
+ toReturn.append(".");
+ toReturn.append(list.get(i));
+ toReturn.append("\n");
+ }
+ }
+ return toReturn.toString();
+ }
+}
diff --git a/src/main/java/command/StartCommand.java b/src/main/java/command/StartCommand.java
new file mode 100644
index 0000000000..3b8cddb70e
--- /dev/null
+++ b/src/main/java/command/StartCommand.java
@@ -0,0 +1,24 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+
+/**
+ * A Command to handle "bye" inputs resulting in a termination of the Duke program.
+ */
+public class StartCommand implements Command {
+ public StartCommand() {
+
+ }
+
+ /**
+ * Prints the bye message via the UI method, UI.bye().
+ *
+ * @param taskList The TaskList used to store the Tasks for this instance of Duke (not used in this method).
+ * @param storage The Storage used to store the Tasks on the hard disk (not used in this method).
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ return UI.start();
+ }
+}
diff --git a/src/main/java/command/TodoCommand.java b/src/main/java/command/TodoCommand.java
new file mode 100644
index 0000000000..58e3b58901
--- /dev/null
+++ b/src/main/java/command/TodoCommand.java
@@ -0,0 +1,41 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Task;
+import task.Todo;
+
+import java.util.ArrayList;
+
+/**
+ * A Command to create an instance of a Todo Task. This will add the Todo Task to the TaskList and the Storage file.
+ */
+public class TodoCommand implements Command {
+ private String todoName;
+
+ public TodoCommand(String todoName) {
+ this.todoName = todoName;
+ }
+
+ /**
+ * Executes the Todo command which creates a Todo Task.
+ *
+ * Taking the TaskList and Storage object of the main Duke class as arguments, this command will create a new
+ * Deadline Task which will then be added to the TaskList and Storage objects. The UI will also be used to print
+ * a newTask message into the console.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ ArrayList list = taskList.getTaskList();
+
+ Task todo = new Todo(todoName);
+
+ taskList.addTaskList(todo);
+ storage.writeToFile(list);
+
+ return UI.newTask(list);
+ }
+}
diff --git a/src/main/java/command/UndoCommand.java b/src/main/java/command/UndoCommand.java
new file mode 100644
index 0000000000..24a5808612
--- /dev/null
+++ b/src/main/java/command/UndoCommand.java
@@ -0,0 +1,33 @@
+package command;
+
+import main.Storage;
+import main.TaskList;
+import main.UI;
+import task.Task;
+
+import java.util.ArrayList;
+
+public class UndoCommand implements Command {
+
+ public UndoCommand() {
+
+ }
+
+ /**
+ * Executes the UndoCommand which deletes the last command.
+ *
+ * Taking the TaskList and Storage object of the main Duke class as arguments, this command will find the
+ * last Task added to the TaskList and delete it.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ ArrayList taskListArray = taskList.getTaskList();
+ Task task = taskListArray.remove(taskListArray.size() - 1);
+
+ storage.writeToFile(taskListArray);
+
+ return UI.undoStart(task);
+ }
+}
diff --git a/src/main/java/command/UnknownCommand.java b/src/main/java/command/UnknownCommand.java
new file mode 100644
index 0000000000..9fd09e00a7
--- /dev/null
+++ b/src/main/java/command/UnknownCommand.java
@@ -0,0 +1,25 @@
+package command;
+
+import exception.UnknownCommandException;
+import main.Storage;
+import main.TaskList;
+
+/**
+ * A Command meant to handle the event in which an unknown command is given by the user.
+ */
+public class UnknownCommand implements Command {
+ public UnknownCommand() {
+
+ }
+
+ /**
+ * Prints into the console the error message when an unknown command is given, via the instantiation of an
+ * UnknownCommandException.
+ *
+ * @param taskList The TaskList from the main Duke object.
+ * @param storage The Storage from the main Duke object.
+ */
+ public String execute(TaskList taskList, Storage storage) {
+ return new UnknownCommandException().toString();
+ }
+}
diff --git a/src/main/java/exception/DeleteException.java b/src/main/java/exception/DeleteException.java
new file mode 100644
index 0000000000..02b44f6c78
--- /dev/null
+++ b/src/main/java/exception/DeleteException.java
@@ -0,0 +1,15 @@
+package exception;
+
+/**
+ * An exception which only occurs if an an error is encountered when a Delete Command is executed.
+ */
+public class DeleteException extends DukeException {
+ public DeleteException() {
+
+ }
+
+ @Override
+ public String toString() {
+ return " ☹ OOPS!!! There was an error with deleting!";
+ }
+}
diff --git a/src/main/java/exception/DoneException.java b/src/main/java/exception/DoneException.java
new file mode 100644
index 0000000000..4c0bcb9b11
--- /dev/null
+++ b/src/main/java/exception/DoneException.java
@@ -0,0 +1,15 @@
+package exception;
+
+/**
+ * An exception which only occurs if an an error is encountered when a Done Command is executed.
+ */
+public class DoneException extends DukeException {
+ public DoneException() {
+
+ }
+
+ @Override
+ public String toString() {
+ return " ☹ OOPS!!! You must specify a Task to be done!";
+ }
+}
diff --git a/src/main/java/exception/DukeException.java b/src/main/java/exception/DukeException.java
new file mode 100644
index 0000000000..564e63bfeb
--- /dev/null
+++ b/src/main/java/exception/DukeException.java
@@ -0,0 +1,13 @@
+package exception;
+
+/**
+ * A custom Exception class which is meant only for exceptions unique to Duke.
+ */
+public abstract class DukeException extends Exception {
+ public DukeException() {
+
+ }
+
+ @Override
+ public abstract String toString();
+}
diff --git a/src/main/java/exception/TaskException.java b/src/main/java/exception/TaskException.java
new file mode 100644
index 0000000000..c1bc672bc6
--- /dev/null
+++ b/src/main/java/exception/TaskException.java
@@ -0,0 +1,15 @@
+package exception;
+
+/**
+ * An exception which only occurs if an an error is encountered when a Task Command is executed.
+ */
+public class TaskException extends DukeException {
+ public TaskException() {
+
+ }
+
+ @Override
+ public String toString() {
+ return " ☹ OOPS!!! The description of a Task cannot be empty.";
+ }
+}
diff --git a/src/main/java/exception/UnknownCommandException.java b/src/main/java/exception/UnknownCommandException.java
new file mode 100644
index 0000000000..6cc2781bdc
--- /dev/null
+++ b/src/main/java/exception/UnknownCommandException.java
@@ -0,0 +1,15 @@
+package exception;
+
+/**
+ * An exception which only occurs if an an error is encountered when a UnknownCommand is executed.
+ */
+public class UnknownCommandException extends DukeException {
+ public UnknownCommandException() {
+
+ }
+
+ @Override
+ public String toString() {
+ return " ☹ OOPS!!! I'm sorry, but I don't know what that means :-(";
+ }
+}
diff --git a/src/main/java/main/Parser.java b/src/main/java/main/Parser.java
new file mode 100644
index 0000000000..cd7b69d882
--- /dev/null
+++ b/src/main/java/main/Parser.java
@@ -0,0 +1,139 @@
+package main;
+
+import command.ByeCommand;
+import command.Command;
+import command.DeadlineCommand;
+import command.DeleteCommand;
+import command.DoneCommand;
+import command.EventCommand;
+import command.FindCommand;
+import command.ListCommand;
+import command.StartCommand;
+import command.TodoCommand;
+import command.UndoCommand;
+import command.UnknownCommand;
+import exception.TaskException;
+
+/**
+ * Parses all the commands input by the user.
+ *
+ * The only public method, parse(), is used to determine which command will be returned and executed in Duke.
+ * The other two methods are private and used to assist the parse() method in processing an Event or a Deadline type
+ * Command.
+ */
+public class Parser {
+ public Parser() {
+
+ }
+
+ /**
+ * Returns a String array which has two elements.
+ *
+ * The first element is the name of the new Event Task and the second element is the String representing the
+ * date of the Event Task.
+ *
+ * @param command A string array representing the initial input split into individual words.
+ * @return Returns a String array which contains the name and the date of a new Event Task.
+ * @throws TaskException Thrown when there is insufficient information to create an Event Task.
+ */
+ private String[] getEventDetails(String[] command) {
+ taskHasName(command);
+ String toReturn = "";
+ for (int i = 1; i < command.length; i++) {
+ toReturn += command[i] + " ";
+ }
+
+ return toReturn.split(" /at ");
+ }
+
+ /**
+ * Returns a String array which has two elements.
+ *
+ * The first element is the name of the new Deadline Task and the second element is the String representing
+ * the date of the Deadline Task.
+ *
+ * @param command A string array representing the initial input split into individual words.
+ * @return Returns a String array which contains the name and the date of a new Deadline Task.
+ * @throws TaskException Thrown when there is insufficient information to create an Deadline Task.
+ */
+ private String[] getDeadlineDetails(String[] command) {
+ taskHasName(command);
+ String toReturn = "";
+ for (int i = 1; i < command.length; i++) {
+ toReturn += command[i] + " ";
+ }
+
+ return toReturn.split(" /by ");
+ }
+
+ private void taskHasName(String[] nextCommand) {
+ assert nextCommand.length > 1 : "Task has no name";
+ }
+
+ private void commandHasTask(String[] nextCommand) {
+ assert nextCommand.length > 1 : "Command has no Task";
+ }
+
+
+ /**
+ * Parses the input and returns a Command that corresponds to the type of input given.
+ *
+ * When a String (commandLine) is supplied, this method will split commandLine into multiple words (via
+ * String.split(" "). This will result in a String array containing individual words. The first word is then used
+ * to determine which Command is to be returned. If an invalid command is given, an UnknownCommand will be returned.
+ *
+ * @param commandLine A string representing a full line of input from the user.
+ * @return Returns a Command object corresponding to the type of input from the user.
+ */
+ public Command parse(String commandLine) {
+ String[] nextCommand = commandLine.split(" ");
+ switch (nextCommand[0]) {
+ case "bye":
+ return new ByeCommand();
+
+ case "list":
+ return new ListCommand();
+
+ case "done":
+ commandHasTask(nextCommand);
+ return new DoneCommand(Integer.valueOf(nextCommand[1]) - 1);
+
+ case "todo":
+ taskHasName(nextCommand);
+ String todoName = "";
+ for (int i = 1; i < nextCommand.length; i++) {
+ todoName += nextCommand[i] + " ";
+ }
+ return new TodoCommand(todoName);
+
+ case "event":
+ String[] eventDetails = getEventDetails(nextCommand);
+ return new EventCommand(eventDetails[0], eventDetails[1]);
+
+
+ case "deadline":
+ String[] deadlineDetails = getDeadlineDetails(nextCommand);
+ return new DeadlineCommand(deadlineDetails[0], deadlineDetails[1]);
+
+ case "delete":
+ commandHasTask(nextCommand);
+ int index = Integer.parseInt(nextCommand[1]);
+ return new DeleteCommand(index);
+
+ case "find":
+ commandHasTask(nextCommand);
+ return new FindCommand(nextCommand[1]);
+
+ case "undo":
+ return new UndoCommand();
+
+ case "hello":
+ return new StartCommand();
+
+ default:
+ break;
+ }
+ return new UnknownCommand();
+ }
+}
+
diff --git a/src/main/java/main/Storage.java b/src/main/java/main/Storage.java
new file mode 100644
index 0000000000..ea7a4d3c80
--- /dev/null
+++ b/src/main/java/main/Storage.java
@@ -0,0 +1,113 @@
+package main;
+
+import task.Deadline;
+import task.Event;
+import task.Task;
+import task.Todo;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+/**
+ * Manages the storing of the TaskList to a file on the hard disk. This allows the list of Tasks to be stored and
+ * accessed for subsequent initialisations of Duke.
+ */
+public class Storage {
+ private Path path = Paths.get(System.getProperty("user.dir"));
+ private File data = new File(path + "/data/duke.txt");
+
+ public Storage() {
+
+ }
+
+ /**
+ * Returns an ArrayList of tasks from the data file on the hard disk.
+ *
+ * This method is invoked whenever an instance of Duke is created. It reads from the data/duke.txt file.
+ * Should the file not be found, a FileNotFoundException is thrown and caught. A parser is also implemented in this
+ * method to read from the data file.
+ *
+ * @return An ArrayList of Tasks from the stored data file.
+ */
+ public ArrayList readFromFile() {
+ ArrayList toReturn = new ArrayList<>();
+
+ try {
+ Scanner sc = new Scanner(data);
+
+ while (sc.hasNextLine()) {
+ String[] next = sc.nextLine().split("-");
+
+ switch (next[0]) {
+ case ("T"):
+ Task todo = new Todo(next[2]);
+
+ if (Integer.valueOf(next[1]) == 1) {
+ todo.setDone();
+ }
+ toReturn.add(todo);
+ break;
+
+
+ case ("E"):
+ Task event = new Event(next[2], next[3]);
+
+ if (Integer.valueOf(next[1]) == 1) {
+ event.setDone();
+ }
+ toReturn.add(event);
+ break;
+
+ case ("D"):
+ Task deadline = new Deadline(next[2], next[3]);
+
+ if (Integer.valueOf(next[1]) == 1) {
+ deadline.setDone();
+ }
+ toReturn.add(deadline);
+ break;
+
+ default:
+ break;
+ }
+ }
+ sc.close();
+ } catch (FileNotFoundException fileExp) {
+ System.out.println(fileExp);
+ }
+
+ return toReturn;
+ }
+
+ /**
+ * Writes all the tasks in a given ArrayList into the data/duke.txt file.
+ *
+ * A StringBuilder is used to concatenate all the strings from the toFile() method of each Task. This is then
+ * stored into the data file.
+ *
+ * @param list ArrayList of all the Tasks to be written into the data file.
+ */
+ public void writeToFile(ArrayList list) {
+ try {
+ File data = new File("duke.txt");
+ FileWriter fw = new FileWriter(data);
+
+ StringBuilder toWrite = new StringBuilder("");
+ for (Task task : list) {
+ toWrite.append(task.toFile() + " \n");
+ }
+
+ fw.write(toWrite.toString());
+ fw.close();
+ } catch (IOException ioExp) {
+ System.err.println(ioExp);
+ }
+ }
+
+}
diff --git a/src/main/java/main/TaskList.java b/src/main/java/main/TaskList.java
new file mode 100644
index 0000000000..f8e7a42101
--- /dev/null
+++ b/src/main/java/main/TaskList.java
@@ -0,0 +1,51 @@
+package main;
+
+import task.Task;
+
+import java.util.ArrayList;
+
+/**
+ * Stores all the Tasks in an ArrayList. Contains methods to access and update the ArrayList of Tasks.
+ */
+public class TaskList {
+ private ArrayList list;
+
+ /**
+ * Instantiates a TaskList object with an empty ArrayList.
+ */
+ public TaskList() {
+ list = new ArrayList<>();
+ }
+
+ /**
+ * Instantiates a TaskList object with an ArrayList of Task (given as an argument).
+ *
+ * @param list an ArrayList of Tasks.
+ */
+ public TaskList(ArrayList list) {
+ this.list = list;
+ }
+
+ /**
+ * Returns the ArrayList of Tasks of this TaskList.
+ *
+ * @return The ArrayList of Tasks of this TaskList.
+ */
+ public ArrayList getTaskList() {
+ return this.list;
+ }
+
+ /**
+ * Replaces the ArrayList of this TaskList with another ArrayList of Tasks (given as an argument).
+ *
+ * @param list An ArrayList of Tasks to replace the ArrayList of this TaskList.
+ */
+ public void updateTaskList(ArrayList list) {
+ this.list = list;
+ }
+
+ public void addTaskList(Task task) {
+ list.add(task);
+ }
+
+}
diff --git a/src/main/java/main/UI.java b/src/main/java/main/UI.java
new file mode 100644
index 0000000000..8279b94a01
--- /dev/null
+++ b/src/main/java/main/UI.java
@@ -0,0 +1,108 @@
+package main;
+
+import task.Task;
+
+import java.util.ArrayList;
+
+/**
+ * Stores all the different messages to be printed to the console. This class only contains static methods and as such
+ * this class will never need to be initialised.
+ */
+public interface UI {
+
+ /**
+ * Prints the start message when Duke is executed.
+ *
+ * @return The start message.
+ */
+ static String start() {
+ return " ________________________________________\n"
+ + " Hello! I am BARELY FUNCTIONING, PLEASE KILL ME\n"
+ + " What can I do for you?\n"
+ + " ______________________________________\n";
+
+ }
+
+ /**
+ * Prints the closing message when a ByeCommand is executed.
+ *
+ * @return The bye message.
+ */
+ static String bye() {
+ return ("Bye. Hope to see you again soon!");
+ }
+
+ /**
+ * Prints the contents of the TaskList (given as an argument) whenever a new task is added to the TaskList.
+ *
+ * @param taskList A TaskList instance unique to each instance of Duke.
+ *
+ * @return The message explaining a new task.
+ */
+ static String newTask(ArrayList taskList) {
+ return "Got it. I've added this task: \n"
+ + " " + taskList.get(taskList.size() - 1) + "\n"
+ + "Now you have " + taskList.size() + " tasks in the list. \n";
+ }
+
+ /**
+ * Prints the size of the TaskList (given as an argument) and the Task to be removed (also given as an argument)
+ * of the TaskList whenever a Task is removed from the TaskList. Typically occurs when a RemoveCommand is executed.
+ *
+ * @param task The Task to be removed from the TaskList.
+ * @param listSize The size of the TaskList, after removal of Task.
+ *
+ * @return The message explaining the deletion of a task.
+ */
+ static String removedTask(Task task, int listSize) {
+ return " Noted. I've removed this task: \n"
+ + " " + task + "\n"
+ + "Now you have " + listSize + " tasks in the list.\n";
+ }
+
+ /**
+ * Prints the number of Tasks in the TaskList (given as an argument).
+ *
+ * @param taskList A TaskList instance unique to each instance of Duke.
+ *
+ * @return The number of tasks in the TaskList.
+ */
+ static String numTasks(ArrayList taskList) {
+ return "Now you have " + taskList.size() + " tasks in the list.\n";
+ }
+
+ /**
+ * Prints that a given Task is designated as done, typically when a DoneCommand is excuted.
+ *
+ * @param task The Task designated as done.
+ *
+ * @return The done message.
+ */
+ static String done(Task task) {
+ return "Nice! I've marked this task as done:\n"
+ + " " + task + "\n";
+ }
+
+ /**
+ * Prints the first portion of a find Command.
+ *
+ * @return The start message when a FindCommand is executed.
+ */
+ static String findStart() {
+ return " Here are the matching tasks in your list: \n";
+ }
+
+ /**
+ * Prints a plain line.
+ *
+ * @return Returns a line.
+ */
+ static String endLine() {
+ return " ____________________________________________________________";
+ }
+
+ static String undoStart(Task task) {
+ return "The last created task has been deleted: \n"
+ + task.toString();
+ }
+}
diff --git a/src/main/java/task/Deadline.java b/src/main/java/task/Deadline.java
new file mode 100644
index 0000000000..4fbf440a89
--- /dev/null
+++ b/src/main/java/task/Deadline.java
@@ -0,0 +1,68 @@
+package task;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * A type of Task that includes a date attribute for the Task to be completed by. Also includes two SimpleDateFormatter.
+ */
+public class Deadline extends Task {
+ private Date date;
+
+ /**
+ * Used for parsing the input from the user and for formatting the date for Storage.
+ */
+ private SimpleDateFormat parser = new SimpleDateFormat("dd/MM/yyyy HHmm");
+
+ /**
+ * Used for formatting the date for printing to console.
+ */
+ private SimpleDateFormat formatter = new SimpleDateFormat("d MMM yyyy, hhmma");
+
+
+ /**
+ * Constructor for a Deadline Task.
+ *
+ * @param name A String which represents the name of the Task.
+ * @param dateString A String which represents the date and time of the Task.
+ */
+ public Deadline(String name, String dateString) {
+ this.name = name;
+
+ try {
+ Date dateTime = parser.parse(dateString);
+ this.date = dateTime;
+ } catch (ParseException parseExp) {
+ System.err.println(parseExp);
+ }
+
+ this.isDone = false;
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be saved into the hard disk's storage file.
+
+ * @return A String representation of this Task formatted for the storage file.
+ */
+ public String toFile() {
+ if (isDone) {
+ return "D-1-" + name + "-" + parser.format(date);
+ } else {
+ return "D-0-" + name + "-" + parser.format(date);
+ }
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be printed into the console.
+ *
+ * @return A String representation of this Task formatted for printing into the console.
+ */
+ public String toString() {
+ if (isDone) {
+ return "[D][\u2713] " + name + " (by: " + formatter.format(date) + ")";
+ } else {
+ return "[D][\u2717] " + name + " (by: " + formatter.format(date) + ")";
+ }
+ }
+}
diff --git a/src/main/java/task/Event.java b/src/main/java/task/Event.java
new file mode 100644
index 0000000000..8f8f0d2985
--- /dev/null
+++ b/src/main/java/task/Event.java
@@ -0,0 +1,69 @@
+package task;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * A type of Task that includes a date attribute for the date in which the Task takes place. Also includes two
+ * SimpleDateFormatter.
+ */
+public class Event extends Task {
+ private Date date;
+
+ /**
+ * Used for parsing the input from the user and for formatting the date for Storage.
+ */
+ private SimpleDateFormat parser = new SimpleDateFormat("dd/MM/yyyy HHmm");
+
+ /**
+ * Used for formatting the date for printing to console.
+ */
+ private SimpleDateFormat formatter = new SimpleDateFormat("d MMM yyyy, hhmma");
+
+
+ /**
+ * Constructor for an Event Task.
+ *
+ * @param name A String representing the name of the Task.
+ * @param dateString A String which represents the date and time of the Task.
+ */
+ public Event(String name, String dateString) {
+ this.name = name;
+
+ try {
+ Date dateTime = parser.parse(dateString);
+ this.date = dateTime;
+ } catch (ParseException parseExp) {
+ System.err.println(parseExp);
+ }
+
+ this.isDone = false;
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be saved into the hard disk's storage file.
+
+ * @return A String representation of this Task formatted for the storage file.
+ */
+ public String toFile() {
+ if (isDone) {
+ return "E-1-" + name + "-" + parser.format(date);
+ } else {
+ return "E-0-" + name + "-" + parser.format(date);
+ }
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be printed into the console.
+ *
+ * @return A String representation of this Task formatted for printing into the console.
+ */
+ public String toString() {
+ if (isDone) {
+ return "[E][\u2713] " + name + " (at: " + formatter.format(date) + ")";
+ } else {
+ return "[E][\u2717] " + name + " (at: " + formatter.format(date) + ")";
+ }
+ }
+}
diff --git a/src/main/java/task/Task.java b/src/main/java/task/Task.java
new file mode 100644
index 0000000000..c414b6e0ac
--- /dev/null
+++ b/src/main/java/task/Task.java
@@ -0,0 +1,60 @@
+package task;
+
+/**
+ * An Abstract Class extended by all the Task type classes.
+ *
+ * Each Task contains a name and an isDone attribute. Two abstract methods (toFile() and toString()) are meant
+ * to be implemented by any classes that extend the Task abstract class.
+ */
+public abstract class Task {
+ /**
+ * Indicates where the current task has been completed.
+ */
+ protected boolean isDone;
+ protected String name;
+
+
+ public Task() {
+
+ }
+
+ public Task(String name) {
+ this.name = name;
+ this.isDone = false;
+ }
+
+ /**
+ * Indicates that this Task has already been completed.
+ */
+ public void setDone() {
+ isDone = true;
+ }
+
+ /**
+ * Returns the name of the Task.
+ *
+ * @return String which is the name of the Task.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be saved into the hard disk's storage file.
+ *
+ * To be implemented by each individual Task class.
+ *
+ * @return A String representation of this Task formatted for the storage file.
+ */
+ public abstract String toFile();
+
+ /**
+ * Returns a String representing the Task in a format to be printed into the console.
+ *
+ * To be implemented by each individual Task class.
+ *
+ * @return A String representation of this Task formatted for printing into the console.
+ */
+ @Override
+ public abstract String toString();
+}
diff --git a/src/main/java/task/Todo.java b/src/main/java/task/Todo.java
new file mode 100644
index 0000000000..49e0c1b2d9
--- /dev/null
+++ b/src/main/java/task/Todo.java
@@ -0,0 +1,38 @@
+package task;
+
+/**
+ * A simple Task which only indicates what task needs to be completed.
+ */
+public class Todo extends Task {
+
+ public Todo(String name) {
+ this.name = name;
+ this.isDone = false;
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be saved into the hard disk's storage file.
+
+ * @return A String representation of this Task formatted for the storage file.
+ */
+ public String toFile() {
+ if (isDone) {
+ return "T-1-" + name;
+ } else {
+ return "T-0-" + name;
+ }
+ }
+
+ /**
+ * Returns a String representing the Task in a format to be printed into the console.
+ *
+ * @return A String representation of this Task formatted for printing into the console.
+ */
+ public String toString() {
+ if (isDone) {
+ return "[T][\u2713] " + name;
+ } else {
+ return "[T][\u2717] " + name;
+ }
+ }
+}
diff --git a/src/main/resources/images/Duke.png b/src/main/resources/images/Duke.png
new file mode 100644
index 0000000000..d893658717
Binary files /dev/null and b/src/main/resources/images/Duke.png differ
diff --git a/src/main/resources/images/User.png b/src/main/resources/images/User.png
new file mode 100644
index 0000000000..3c82f45461
Binary files /dev/null and b/src/main/resources/images/User.png differ
diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml
new file mode 100644
index 0000000000..bca6953a1e
--- /dev/null
+++ b/src/main/resources/view/DialogBox.fxml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
new file mode 100644
index 0000000000..64ec483b43
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/main/TaskListTest.java b/src/test/java/main/TaskListTest.java
new file mode 100644
index 0000000000..868db341b5
--- /dev/null
+++ b/src/test/java/main/TaskListTest.java
@@ -0,0 +1,41 @@
+package main;
+
+import task.Task;
+import task.Todo;
+
+import java.util.ArrayList;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class TaskListTest {
+
+ @org.junit.jupiter.api.Test
+ void getTaskList() {
+ assertEquals(new ArrayList(), new TaskList().getTaskList());
+ }
+
+ @org.junit.jupiter.api.Test
+ void updateTaskList() {
+ ArrayList arrList = new ArrayList<>();
+ arrList.add(new Todo("name"));
+
+ TaskList taskList = new TaskList();
+ taskList.updateTaskList(arrList);
+
+
+ assertEquals(arrList, taskList.getTaskList());
+ }
+
+ @org.junit.jupiter.api.Test
+ void addTaskList() {
+ ArrayList arrList = new ArrayList<>();
+ Todo todo = new Todo("name");
+
+ TaskList taskList = new TaskList(arrList);
+ taskList.addTaskList(todo);
+
+
+ arrList.add(new Todo("name"));
+ assertEquals(arrList, taskList.getTaskList());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/task/DeadlineTest.java b/src/test/java/task/DeadlineTest.java
new file mode 100644
index 0000000000..3c495e3696
--- /dev/null
+++ b/src/test/java/task/DeadlineTest.java
@@ -0,0 +1,16 @@
+package task;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class DeadlineTest {
+
+ @org.junit.jupiter.api.Test
+ public void toFile() {
+ assertEquals("D-0-name-11/11/1991 1700", new Deadline("name", "11/11/1991 1700").toFile());
+ }
+
+ @org.junit.jupiter.api.Test
+ public void toString1() {
+ assertEquals("[D][✗] name (by: 11 Nov 1991, 0500PM)", new Deadline("name","11/11/1991 1700").toString());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/task/EventTest.java b/src/test/java/task/EventTest.java
new file mode 100644
index 0000000000..94f68bf987
--- /dev/null
+++ b/src/test/java/task/EventTest.java
@@ -0,0 +1,16 @@
+package task;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class EventTest {
+
+ @org.junit.jupiter.api.Test
+ public void toFile() {
+ assertEquals("E-0-name-11/11/1991 1700", new Event("name", "11/11/1991 1700").toFile());
+ }
+
+ @org.junit.jupiter.api.Test
+ public void toString1() {
+ assertEquals("[E][✗] name (at: 11 Nov 1991, 0500PM)", new Event("name","11/11/1991 1700").toString());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/task/TaskTest.java b/src/test/java/task/TaskTest.java
new file mode 100644
index 0000000000..a9d599e89d
--- /dev/null
+++ b/src/test/java/task/TaskTest.java
@@ -0,0 +1,13 @@
+package task;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class TaskTest {
+
+ @org.junit.jupiter.api.Test
+ void setDone() {
+ Task task = new Todo("name");
+ task.setDone();
+ assertEquals("[T][✓] name", task.toString());
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/task/TodoTest.java b/src/test/java/task/TodoTest.java
new file mode 100644
index 0000000000..6a5d63550b
--- /dev/null
+++ b/src/test/java/task/TodoTest.java
@@ -0,0 +1,16 @@
+package task;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class TodoTest {
+
+ @org.junit.jupiter.api.Test
+ public void toFile() {
+ assertEquals("T-0-name", new Todo("name").toFile());
+ }
+
+ @org.junit.jupiter.api.Test
+ public void toString1() {
+ assertEquals("[T][✗] name", new Todo("name").toString());
+ }
+}
\ No newline at end of file