diff --git a/.gitignore b/.gitignore
index f69985ef1f..389c54f104 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,6 @@ bin/
/text-ui-test/ACTUAL.txt
text-ui-test/EXPECTED-UNIX.TXT
+
+# Remove .class files
+*.class
diff --git a/README.md b/README.md
index 9d95025bce..d4adcda27f 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. Click `Open or Import`.
1. Select the project directory, and click `OK`
1. If there are any further prompts, accept the defaults.
-1. After the importing is complete, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()`. If the setup is correct, you should see something like the below:
+1. After the importing is complete, locate the `src/main/java/duke.main.Duke.java` file, right-click it, and choose `Run duke.main.Duke.main()`. If the setup is correct, you should see something like the below:
```
Hello from
____ _
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..46b9671e45
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,60 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'checkstyle'
+ id 'com.github.johnrengelman.shadow' version '5.1.0'
+}
+
+repositories {
+ mavenCentral()
+}
+
+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'
+ testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0'
+ testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0'
+}
+
+test {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed"
+
+ showExceptions true
+ exceptionFormat "full"
+ showCauses true
+ showStackTraces true
+ showStandardStreams = false
+ }
+}
+
+application {
+ mainClassName = "duke.Launcher"
+}
+
+shadowJar {
+ archiveBaseName = "duke"
+ archiveClassifier = null
+}
+
+checkstyle {
+ toolVersion = '8.29'
+}
+
+run{
+ standardInput = System.in
+}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000000..4c001417ae
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,403 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
new file mode 100644
index 0000000000..39efb6e4ac
--- /dev/null
+++ b/config/checkstyle/suppressions.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
diff --git a/data/tasks.txt b/data/tasks.txt
new file mode 100644
index 0000000000..c14c4d36e2
--- /dev/null
+++ b/data/tasks.txt
@@ -0,0 +1 @@
+E,1,borrow book,2019-04-18 0000
diff --git a/docs/README.md b/docs/README.md
index fd44069597..d63eb4ea64 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -2,19 +2,106 @@
## Features
-### Feature 1
-Description of feature.
+### CRUD Operations
+
+Able to Create, Read, Update and Delete Tasks
## Usage
-### `Keyword` - Describe action
+##### `todo [String]` - Add a todo task
+
+Creates a new todo task
+
+Example of usage:
+
+`todo borrow book`
+
+Expected outcome:
+
+```
+Got it. I've added this task:
+[T][X] read book
+Now you have 1 tasks in the list.
+```
+
+##### `event [String] /at YYYY-MM-DD HHMM` - Add an event task
+
+Creates a new event task on a particular date and time
+
+Example of usage:
+
+`event borrow book /at 2019-04-18 1400`
+
+Expected outcome:
+
+```
+Got it. I've added this task:
+[E][X] borrow book (at: Apr 18 2019, 2.00pm)
+Now you have 2 tasks in the list.
+```
+
+##### `deadline [String] /by YYYY-MM-DD HHMM` - Add a deadline task
+
+Creates a new deadline task on a particular date and time
+
+Example of usage:
+
+`deadline return book /at 2019-04-26 1800`
+
+Expected outcome:
+
+```
+Got it. I've added this task:
+[D][X] return book (at: Apr 26 2019, 6.00pm)
+Now you have 3 tasks in the list.
+```
+
+##### `list` - Lists all tasks
+
+Lists all the saved tasks
+
+Example of usage:
+
+`list`
+
+Expected outcome:
+
+```
+1.[T][X] read book
+2.[E][X] borrow book (at: Apr 18 2019, 2.00pm)
+3.[D][X] return book (at: Apr 26 2019, 6.00pm)
+```
+
+##### `done [Integer]` - Complete a task
-Describe action and its outcome.
+Completes a task according to the task number provided
Example of usage:
-`keyword (optional arguments)`
+`done 1`
Expected outcome:
-`outcome`
+```
+Nice! I've marked this task as done:
+[T][✓] read book
+```
+
+##### `delete [Integer]` - Deletes a task
+
+Deletes a task according to the task number provided
+
+Example of usage:
+
+`delete 1`
+
+Expected outcome:
+
+```
+Noted. I've removed this task:
+[T][✓] read book
+Now you have 2 tasks in the list.
+```
+
+
+
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..9843a67219
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..fc24e7a62d
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-hacker
\ 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..f3d88b1c2f
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..b7c8c5dbf5
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000000..2fe81a7d95
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,183 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000000..62bd9b9cce
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,103 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java
deleted file mode 100644
index 5d313334cc..0000000000
--- a/src/main/java/Duke.java
+++ /dev/null
@@ -1,10 +0,0 @@
-public class Duke {
- public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
- }
-}
diff --git a/src/main/java/Duke/Errors/DateFormatException.java b/src/main/java/Duke/Errors/DateFormatException.java
new file mode 100644
index 0000000000..0a4c129c7b
--- /dev/null
+++ b/src/main/java/Duke/Errors/DateFormatException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type DateFormatException exception.
+ */
+public class DateFormatException extends DukeException {
+ /**
+ * Instantiates a new DateFormatException exception.
+ */
+ public DateFormatException() {
+ super("☹ OOPS!!! Please enter date format as yyyy-mm-dd hhmm, e.g. 2019-12-01 1800");
+ }
+}
diff --git a/src/main/java/Duke/Errors/DeadlineException.java b/src/main/java/Duke/Errors/DeadlineException.java
new file mode 100644
index 0000000000..a300d0973b
--- /dev/null
+++ b/src/main/java/Duke/Errors/DeadlineException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type Deadline exception.
+ */
+public class DeadlineException extends DukeException {
+ /**
+ * Instantiates a new Deadline exception.
+ */
+ public DeadlineException() {
+ super("☹ OOPS!!! Please include a /by");
+ }
+}
diff --git a/src/main/java/Duke/Errors/DukeException.java b/src/main/java/Duke/Errors/DukeException.java
new file mode 100644
index 0000000000..bfb073d417
--- /dev/null
+++ b/src/main/java/Duke/Errors/DukeException.java
@@ -0,0 +1,15 @@
+package duke.errors;
+
+/**
+ * The type Duke exception.
+ */
+public class DukeException extends Exception {
+ /**
+ * Instantiates a new Duke exception.
+ *
+ * @param errorMessage the error message
+ */
+ public DukeException(String errorMessage) {
+ super(errorMessage);
+ }
+}
diff --git a/src/main/java/Duke/Errors/DuplicateTaskException.java b/src/main/java/Duke/Errors/DuplicateTaskException.java
new file mode 100644
index 0000000000..6bbc2b7eea
--- /dev/null
+++ b/src/main/java/Duke/Errors/DuplicateTaskException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type DuplicateTaskException command exception.
+ */
+public class DuplicateTaskException extends DukeException {
+ /**
+ * Instantiates a new DuplicateTaskException command exception.
+ */
+ public DuplicateTaskException() {
+ super("☹ OOPS!!! That is a duplicate task!!");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Duke/Errors/EmptyDescException.java b/src/main/java/Duke/Errors/EmptyDescException.java
new file mode 100644
index 0000000000..4d8d2ee1bf
--- /dev/null
+++ b/src/main/java/Duke/Errors/EmptyDescException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type Empty desc exception.
+ */
+public class EmptyDescException extends DukeException {
+ /**
+ * Instantiates a new Empty desc exception.
+ */
+ public EmptyDescException() {
+ super("☹ OOPS!!! The description cannot be empty");
+ }
+}
diff --git a/src/main/java/Duke/Errors/EventTaskException.java b/src/main/java/Duke/Errors/EventTaskException.java
new file mode 100644
index 0000000000..0aa66005cb
--- /dev/null
+++ b/src/main/java/Duke/Errors/EventTaskException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type Event task exception.
+ */
+public class EventTaskException extends DukeException {
+ /**
+ * Instantiates a new Event task exception.
+ */
+ public EventTaskException() {
+ super("☹ OOPS!!! Please include a /at");
+ }
+}
diff --git a/src/main/java/Duke/Errors/InvalidCommandException.java b/src/main/java/Duke/Errors/InvalidCommandException.java
new file mode 100644
index 0000000000..ca1d14be7a
--- /dev/null
+++ b/src/main/java/Duke/Errors/InvalidCommandException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type Invalid command exception.
+ */
+public class InvalidCommandException extends DukeException {
+ /**
+ * Instantiates a new Invalid command exception.
+ */
+ public InvalidCommandException() {
+ super("☹ OOPS!!! That is an invalid command");
+ }
+}
diff --git a/src/main/java/Duke/Errors/InvalidIndexException.java b/src/main/java/Duke/Errors/InvalidIndexException.java
new file mode 100644
index 0000000000..f3c4cf3508
--- /dev/null
+++ b/src/main/java/Duke/Errors/InvalidIndexException.java
@@ -0,0 +1,13 @@
+package duke.errors;
+
+/**
+ * The type Invalid index exception.
+ */
+public class InvalidIndexException extends DukeException {
+ /**
+ * Instantiates a new Invalid index exception.
+ */
+ public InvalidIndexException() {
+ super("☹ OOPS!!! The item does not exist within the list");
+ }
+}
diff --git a/src/main/java/Duke/Launcher.java b/src/main/java/Duke/Launcher.java
new file mode 100644
index 0000000000..0e3539bb77
--- /dev/null
+++ b/src/main/java/Duke/Launcher.java
@@ -0,0 +1,19 @@
+package duke;
+
+import duke.fxml.Main;
+import javafx.application.Application;
+
+/**
+ * The type Launcher.
+ */
+public class Launcher {
+ /**
+ * The entry point of application.
+ *
+ * @param args the input arguments
+ */
+ public static void main(String[] args) {
+ Application.launch(Main.class, args);
+ }
+}
+
diff --git a/src/main/java/Duke/Main/Command.java b/src/main/java/Duke/Main/Command.java
new file mode 100644
index 0000000000..fbff79577b
--- /dev/null
+++ b/src/main/java/Duke/Main/Command.java
@@ -0,0 +1,169 @@
+package duke.main;
+
+import duke.errors.DeadlineException;
+import duke.errors.EmptyDescException;
+import duke.errors.EventTaskException;
+import duke.errors.InvalidCommandException;
+import duke.errors.InvalidIndexException;
+import duke.tasks.Deadline;
+import duke.tasks.Event;
+import duke.tasks.Task;
+import duke.tasks.Todo;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * The type Command.
+ */
+public class Command {
+ /**
+ * Todo command string.
+ *
+ * @param arr the arr
+ * @param comText the com text
+ * @param tasks the tasks
+ * @return the string
+ * @throws Exception the exception
+ */
+ public static String todoCommand(String[] arr, String comText, TaskList tasks) throws Exception {
+ if (arr.length == 1) {
+ throw new EmptyDescException();
+ } else {
+ Task todo = new Todo(comText, "0");
+ tasks.addTask(todo.getStringArr());
+ return String.format(
+ "Got it. I've added this task:" +
+ "\n%s\nNow you have %d tasks in the list.", todo,
+ tasks.getSize()
+ );
+ }
+ }
+
+ /**
+ * Event command string.
+ *
+ * @param arr the arr
+ * @param comText the com text
+ * @param tasks the tasks
+ * @return the string
+ * @throws Exception the exception
+ */
+ public static String eventCommand(String[] arr, String comText, TaskList tasks) throws Exception {
+ int eIdx = comText.lastIndexOf("/at");
+ if (arr.length == 1) {
+ throw new EmptyDescException();
+ } else if (eIdx == -1 || comText.length() == (eIdx + 3)) {
+ throw new EventTaskException();
+ } else {
+ String desc = comText.substring(0, eIdx - 1);
+ String at = comText.substring(eIdx + 4, comText.length()).trim();
+
+ LocalDateTime eventDate = Parser.strToDate(at);
+ Task event = new Event(desc, "0", eventDate);
+ tasks.addTask(event.getStringArr());
+ return String.format(
+ "Got it. I've added this task:" +
+ "\n%s\nNow you have %d tasks in the list.", event,
+ tasks.getSize()
+ );
+ }
+ }
+
+ /**
+ * Deadline command string.
+ *
+ * @param arr the arr
+ * @param comText the com text
+ * @param tasks the tasks
+ * @return the string
+ * @throws Exception the exception
+ */
+ public static String deadlineCommand(String[] arr, String comText, TaskList tasks) throws Exception {
+ int dIdx = comText.lastIndexOf("/by");
+ if (arr.length == 1) {
+ throw new EmptyDescException();
+ } else if (dIdx == -1 || comText.length() == (dIdx + 3)) {
+ throw new DeadlineException();
+ } else {
+ String desc = comText.substring(0, dIdx - 1);
+ String by = comText.substring(dIdx + 4, comText.length()).trim();
+
+ LocalDateTime deadlineDate = Parser.strToDate(by);
+ Task deadline = new Deadline(desc, "0", deadlineDate);
+ tasks.addTask(deadline.getStringArr());
+ return String.format(
+ "Got it. I've added this task:" +
+ "\n%s\nNow you have %d tasks in the list.",
+ deadline, tasks.getSize()
+ );
+ }
+ }
+
+ /**
+ * Done command string.
+ *
+ * @param arr the arr
+ * @param comText the com text
+ * @param tasks the tasks
+ * @return the string
+ * @throws Exception the exception
+ */
+ public static String doneCommand(String[] arr, String comText, TaskList tasks) throws Exception {
+ if (arr.length != 2) {
+ throw new InvalidCommandException();
+ }
+ int doneNum = Integer.parseInt(arr[1]);
+ if (doneNum > tasks.getSize() || doneNum < 0) {
+ throw new InvalidIndexException();
+ } else {
+ Task item = tasks.completeTask(doneNum);
+ return String.format(
+ "Nice! I've marked this task as done:\n%s",
+ item
+ );
+ }
+ }
+
+ /**
+ * Delete command string.
+ *
+ * @param arr the arr
+ * @param comText the com text
+ * @param tasks the tasks
+ * @return the string
+ * @throws Exception the exception
+ */
+ public static String deleteCommand(String[] arr, String comText, TaskList tasks) throws Exception {
+ if (arr.length != 2) {
+ throw new InvalidCommandException();
+ }
+ int deleteNum = Integer.parseInt(arr[1]);
+ if (deleteNum > tasks.getSize() || deleteNum < 0) {
+ throw new InvalidIndexException();
+ } else {
+ Task item = tasks.deleteTask(deleteNum);
+ return String.format(
+ "Noted. I've removed this task:\n%s" + "\nNow you have %d tasks in the list.", item,
+ tasks.getSize()
+ );
+ }
+ }
+
+ /**
+ * Find command string.
+ *
+ * @param comText the com text
+ * @param tasks the tasks
+ * @return the string
+ * @throws Exception the exception
+ */
+ public static String findCommand(String comText, TaskList tasks) throws Exception {
+ List foundTasks = tasks.findTasks(comText);
+ return String.format(
+ "Here are the matching tasks in your list:\n%s",
+ Ui.getList(foundTasks)
+ );
+ }
+
+}
diff --git a/src/main/java/Duke/Main/Duke.java b/src/main/java/Duke/Main/Duke.java
new file mode 100644
index 0000000000..57b1f5f14c
--- /dev/null
+++ b/src/main/java/Duke/Main/Duke.java
@@ -0,0 +1,37 @@
+package duke.main;
+
+/**
+ * Duke is a chatbot that allows crud operations, and can add three different types of task,
+ * namely todo, events, and deadlines
+ */
+public class Duke {
+ private Storage storage;
+ private TaskList tasks;
+ private Ui ui;
+
+ /**
+ * Instantiates a new Duke.
+ *
+ * @param filePath the file path
+ */
+ public Duke(String filePath) {
+ this.ui = new Ui();
+ this.storage = new Storage(filePath);
+ try {
+ this.tasks = new TaskList(storage);
+ } catch (Exception e) {
+ ui.showLoadingError();
+ }
+ }
+
+ /**
+ * You should have your own function to generate a response to user input.
+ * Replace this stub with your completed method.
+ *
+ * @param input the input
+ * @return the response
+ */
+ public String getResponse(String input) {
+ return this.ui.commandParser(input, this.tasks);
+ }
+}
diff --git a/src/main/java/Duke/Main/Parser.java b/src/main/java/Duke/Main/Parser.java
new file mode 100644
index 0000000000..e39b7387e8
--- /dev/null
+++ b/src/main/java/Duke/Main/Parser.java
@@ -0,0 +1,59 @@
+package duke.main;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+import duke.errors.InvalidCommandException;
+import duke.errors.DateFormatException;
+
+/**
+ * The type Parser.
+ */
+public class Parser {
+ /**
+ * Converts a date string into LocalDateTime object
+ *
+ * @param by the by
+ * @return LocalDateTime object
+ * @throws Exception the exception
+ */
+ public static LocalDateTime strToDate(String by) throws Exception {
+ String[] arr = by.split("\\s+");
+ LocalDate localDate;
+ LocalDateTime localDateTime;
+ try {
+ if (arr.length == 1) {
+ // Only date provided
+ String date = arr[0].replace("/", "-");
+ localDate = LocalDate.parse(date);
+ localDateTime = localDate.atTime(0, 0);
+ } else if (arr.length == 2 && arr[1].length() == 4) {
+ // Date and time provided
+ String date = arr[0].replace("/", "-");
+ localDate = LocalDate.parse(date);
+ String time = arr[1];
+ int hours = Integer.parseInt(time.substring(0, 2));
+ int minutes = Integer.parseInt(time.substring(2, 4));
+
+ localDateTime = localDate.atTime(hours, minutes);
+ } else {
+ throw new InvalidCommandException();
+ }
+
+ return localDateTime;
+ } catch (Exception e) {
+ throw new DateFormatException();
+ }
+ }
+
+ /**
+ * Parses a LocalDateTime object into a String for printing on Duke
+ *
+ * @param datetime LocalDateTime object
+ * @return Parsed String
+ */
+ public static String parseDateTime(LocalDateTime datetime) {
+ return datetime.format(DateTimeFormatter.ofPattern("MMM d yyyy, h.mma"));
+ }
+}
diff --git a/src/main/java/Duke/Main/Storage.java b/src/main/java/Duke/Main/Storage.java
new file mode 100644
index 0000000000..2660e8d11e
--- /dev/null
+++ b/src/main/java/Duke/Main/Storage.java
@@ -0,0 +1,119 @@
+package duke.main;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import duke.tasks.Deadline;
+import duke.tasks.Event;
+import duke.tasks.Task;
+import duke.tasks.Todo;
+
+/**
+ * The type Storage.
+ */
+public class Storage {
+ private String filepath;
+
+ /**
+ * Instantiates a new Storage.
+ *
+ * @param filepath the filepath
+ */
+ public Storage(String filepath) {
+ File file = new File(filepath);
+
+ //Create the file if it does not exist
+ try {
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ } catch (Exception e) {
+ System.out.println("Error occurred while creating file in Storage");
+ }
+
+ this.filepath = filepath;
+ }
+
+ /**
+ * Resets the entire txt file
+ * @throws IOException
+ */
+ private void resetFile() throws IOException {
+ FileWriter fw = new FileWriter(filepath, false);
+ fw.close();
+ }
+
+ /**
+ * Appends string to txt file
+ *
+ * @param textToAppend the text to append
+ * @throws IOException the io exception
+ */
+ public void appendToFile(String textToAppend) throws IOException {
+ FileWriter fw = new FileWriter(filepath, true); // create a FileWriter in append mode
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(textToAppend);
+ bw.close();
+ }
+
+ /**
+ * Returns the entire txt file
+ *
+ * @return List of Tasks from file
+ * @throws Exception the exception
+ */
+ public List getFileContents() throws Exception {
+ FileReader fr = new FileReader(filepath);
+ BufferedReader br = new BufferedReader(fr);
+ List lst = new ArrayList<>();
+ String line = br.readLine();
+ while (line != null) {
+ String[] arr = line.split(",");
+ String type = arr[0];
+ String checked = arr[1];
+ String desc = arr[2];
+ switch (type) {
+ case "T":
+ Task todo = new Todo(desc, checked);
+ lst.add(todo);
+ break;
+ case "E":
+ Task event = new Event(desc, checked, Parser.strToDate(arr[3]));
+ lst.add(event);
+ break;
+ case "D":
+ Task deadline = new Deadline(desc, checked, Parser.strToDate(arr[3]));
+ lst.add(deadline);
+ break;
+ default:
+ break;
+ }
+ line = br.readLine();
+ }
+ br.close();
+ return lst;
+ }
+
+ /**
+ * Rewrites the file contents, each line corresponding to each element of list
+ *
+ * @param lst the lst
+ */
+ public void rewriteFileContents(List lst) {
+ try {
+ resetFile();
+ for (int i = 0; i < lst.size(); i++) {
+ String[] arr = lst.get(i).getStringArr();
+ String s = Task.stringFormat(arr);
+ appendToFile(s);
+ }
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+}
diff --git a/src/main/java/Duke/Main/TaskList.java b/src/main/java/Duke/Main/TaskList.java
new file mode 100644
index 0000000000..bb55255de4
--- /dev/null
+++ b/src/main/java/Duke/Main/TaskList.java
@@ -0,0 +1,161 @@
+package duke.main;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import duke.errors.DuplicateTaskException;
+import duke.errors.InvalidIndexException;
+import duke.tasks.Task;
+
+/**
+ * The type Task list.
+ */
+public class TaskList {
+ /**
+ * The Storage.
+ */
+ private Storage storage;
+
+ /**
+ * Instantiates a new Task list.
+ *
+ * @param storage the storage
+ */
+ public TaskList(Storage storage) {
+ this.storage = storage;
+ /*
+ - Values are constantly updated to prevent User's data
+ from disappearing if they quit halfway through.
+ - This however reduces the efficiency as it has to
+ pull and push to the txt file each time.
+ */
+ }
+
+ /**
+ * Gets list.
+ *
+ * @return the list
+ * @throws Exception the exception
+ */
+ public List getList() throws Exception {
+ return storage.getFileContents();
+ }
+
+ /**
+ * Checks if index is within acceptable range
+ *
+ * @param i index for fileContents
+ * @param fileContents List of Tasks
+ * @throws Exception the exception
+ */
+ private void checkIndex(int i, List fileContents) throws Exception {
+ boolean greaterThanOne = i > 0;
+ boolean smallerThanFileSize = i <= fileContents.size();
+ assert (greaterThanOne || smallerThanFileSize) : "Index out of range";
+ if (!(greaterThanOne && smallerThanFileSize)) {
+ throw new InvalidIndexException();
+ }
+ }
+
+ /**
+ * Pulls from txt file into a Task object
+ *
+ * @param i Line to get
+ * @return Task object
+ * @throws Exception the exception
+ */
+ public Task getTask(int i) throws Exception {
+ List fileContents = storage.getFileContents();
+
+ checkIndex(i, fileContents);
+
+ return fileContents.get(i - 1);
+ }
+
+ /**
+ * Adds a Task into txt file as a string
+ *
+ * @param arr Array of respective values representing a Task
+ * @throws Exception the exception
+ */
+ public void addTask(String[] arr) throws Exception {
+ List fileContents = storage.getFileContents();
+
+ // We append first since it helps us to parse into the correct format
+ String dataToStore = Task.stringFormat(arr);
+ storage.appendToFile(dataToStore);
+
+ // Check for duplicate and delete
+ int newFileSize = getSize();
+ Task addedTask = getTask(newFileSize);
+ for (int i = 0; i < fileContents.size(); i++) {
+ if ((fileContents.get(i)).equals(addedTask)) {
+ // Delete newly added task if it's a duplicate
+ deleteTask(newFileSize);
+ throw new DuplicateTaskException();
+ }
+ }
+ }
+
+ /**
+ * Completes a Task
+ *
+ * @param i Line to update
+ * @return Completed Task object
+ * @throws Exception the exception
+ */
+ public Task completeTask(int i) throws Exception {
+ List fileContents = storage.getFileContents();
+ checkIndex(i, fileContents);
+
+ Task t = fileContents.get(i - 1);
+
+ fileContents.get(i - 1).setStatus("1");
+ storage.rewriteFileContents(fileContents);
+ return t;
+ }
+
+ /**
+ * Deletes a Task
+ *
+ * @param i Line to delete
+ * @return Delete Task object
+ * @throws Exception the exception
+ */
+ public Task deleteTask(int i) throws Exception {
+ List fileContents = storage.getFileContents();
+ checkIndex(i, fileContents);
+
+ Task t = fileContents.get(i - 1);
+
+ fileContents.remove(i - 1);
+ storage.rewriteFileContents(fileContents);
+ return t;
+ }
+
+ /**
+ * Find List of Tasks by filter
+ *
+ * @param filter Text to filter Task Descriptions
+ * @return List of filtered Tasks
+ * @throws Exception the exception
+ */
+ public List findTasks(String filter) throws Exception {
+ List filteredContents = storage.getFileContents()
+ .stream()
+ .filter(Task -> Task.getDescription().contains(filter))
+ .collect(Collectors.toList());
+ return filteredContents;
+ }
+
+ /**
+ * Gets total number of lines on txt
+ *
+ * @return size size
+ * @throws Exception the exception
+ */
+ public int getSize() throws Exception {
+ List fileContents = storage.getFileContents();
+ return fileContents.size();
+ }
+}
diff --git a/src/main/java/Duke/Main/Ui.java b/src/main/java/Duke/Main/Ui.java
new file mode 100644
index 0000000000..5cccb25119
--- /dev/null
+++ b/src/main/java/Duke/Main/Ui.java
@@ -0,0 +1,97 @@
+package duke.main;
+
+import java.util.List;
+
+import duke.errors.InvalidCommandException;
+import duke.tasks.Task;
+
+/**
+ * The type Ui.
+ */
+public class Ui {
+ /**
+ * Show loading error.
+ */
+ public void showLoadingError() {
+ System.out.println("☹ OOPS!!! An error occurred while loading from the .txt file");
+ }
+
+ /**
+ * Gets the provided List
+ *
+ * @param lst List of Tasks
+ * @return the list
+ */
+ public static String getList(List lst) {
+ String s = "";
+ for (int i = 1; i <= lst.size(); i++) {
+ Task item = lst.get(i - 1);
+ s += String.format("%d.%s", i, item);
+ s += (i == lst.size()) ? "" : "\n";
+ }
+ return s;
+ }
+
+ /**
+ * Parses String array into String
+ *
+ * @param strArr array of String
+ * @return parsed String
+ */
+ public String textParser(String[] strArr) {
+ String comText = "";
+ for (int i = 1; i < strArr.length; i++) {
+ comText += strArr[i] + " ";
+ }
+ return comText.trim();
+ }
+
+ /**
+ * Takes the input from user, runs the relevant command
+ *
+ * @param sentence user input
+ * @param tasks tasks handler to interact with database
+ * @return output to acknowledge user's command
+ */
+ public String commandParser(String sentence, TaskList tasks) {
+ String[] arr = sentence.split("\\s+");
+ String command = arr[0];
+ String comText = textParser(arr);
+
+ String returnStr;
+ try {
+ switch (command) {
+ case "todo":
+ returnStr = Command.todoCommand(arr, comText, tasks);
+ break;
+ case "deadline":
+ returnStr = Command.deadlineCommand(arr, comText, tasks);
+ break;
+ case "event":
+ returnStr = Command.eventCommand(arr, comText, tasks);
+ break;
+ case "find":
+ returnStr = Command.findCommand(comText, tasks);
+ break;
+ case "list":
+ returnStr = Ui.getList(tasks.getList());
+ break;
+ case "done":
+ returnStr = Command.doneCommand(arr, comText, tasks);
+ break;
+ case "delete":
+ returnStr = Command.deleteCommand(arr, comText, tasks);
+ break;
+ case "bye":
+ returnStr = "Bye. Hope to see you again soon!";
+ break;
+ default:
+ throw new InvalidCommandException();
+ }
+ } catch (Exception e) {
+ returnStr = e.getMessage();
+ }
+
+ return returnStr;
+ }
+}
diff --git a/src/main/java/Duke/Tasks/Deadline.java b/src/main/java/Duke/Tasks/Deadline.java
new file mode 100644
index 0000000000..2d5fe3e275
--- /dev/null
+++ b/src/main/java/Duke/Tasks/Deadline.java
@@ -0,0 +1,42 @@
+package duke.tasks;
+
+import java.time.LocalDateTime;
+
+import duke.main.Parser;
+
+/**
+ * The type Deadline.
+ */
+public class Deadline extends Task {
+
+ /**
+ * The By.
+ */
+ protected LocalDateTime by;
+
+ /**
+ * Instantiates a new Deadline.
+ *
+ * @param description the description
+ * @param done the done
+ * @param by the by
+ */
+ public Deadline(String description, String done, LocalDateTime by) {
+ super(description, done);
+ this.by = by;
+ }
+
+ @Override
+ public String[] getStringArr() {
+ String[] stringArr = this.by.toString().split("T");
+ String[] timeArr = stringArr[1].split(":");
+ String t = String.format("%s %s%s", stringArr[0], timeArr[0], timeArr[1]);
+ String[] arr = { "D", super.done, super.description, t };
+ return arr;
+ }
+
+ @Override
+ public String toString() {
+ return "[D]" + super.toString() + " (by: " + Parser.parseDateTime(this.by) + ")";
+ }
+}
diff --git a/src/main/java/Duke/Tasks/Event.java b/src/main/java/Duke/Tasks/Event.java
new file mode 100644
index 0000000000..dec26cc269
--- /dev/null
+++ b/src/main/java/Duke/Tasks/Event.java
@@ -0,0 +1,42 @@
+package duke.tasks;
+
+import java.time.LocalDateTime;
+
+import duke.main.Parser;
+
+/**
+ * The type Event.
+ */
+public class Event extends Task {
+
+ /**
+ * The At.
+ */
+ protected LocalDateTime at;
+
+ /**
+ * Instantiates a new Event.
+ *
+ * @param description the description
+ * @param done the done
+ * @param at the at
+ */
+ public Event(String description, String done, LocalDateTime at) {
+ super(description, done);
+ this.at = at;
+ }
+
+ @Override
+ public String[] getStringArr() {
+ String[] stringArr = this.at.toString().split("T");
+ String[] timeArr = stringArr[1].split(":");
+ String t = String.format("%s %s%s", stringArr[0], timeArr[0], timeArr[1]);
+ String[] arr = { "E", super.done, super.description, t };
+ return arr;
+ }
+
+ @Override
+ public String toString() {
+ return "[E]" + super.toString() + " (at: " + Parser.parseDateTime(this.at) + ")";
+ }
+}
diff --git a/src/main/java/Duke/Tasks/Task.java b/src/main/java/Duke/Tasks/Task.java
new file mode 100644
index 0000000000..8729cc077e
--- /dev/null
+++ b/src/main/java/Duke/Tasks/Task.java
@@ -0,0 +1,100 @@
+package duke.tasks;
+
+import duke.errors.InvalidCommandException;
+
+/**
+ * The type Task.
+ */
+public abstract class Task {
+ /**
+ * The Description.
+ */
+ protected String description;
+ /**
+ * The Done.
+ */
+ protected String done;
+
+ /**
+ * Instantiates a new Task.
+ *
+ * @param description the description
+ * @param done the done
+ */
+ public Task(String description, String done) {
+ this.description = description;
+ this.done = done;
+ }
+
+ /**
+ * Getter method to get Task Description
+ *
+ * @return Task Description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Takes in an array of Task values to form into a String to be stored on database
+ *
+ * @param arr String Array of Task values
+ * @return String to be saved to database
+ * @throws Exception the exception
+ */
+ public static String stringFormat(String[] arr) throws Exception {
+ String s;
+ switch (arr[0]) {
+ case "T":
+ s = String.format("%s,%s,%s\n", arr[0], arr[1], arr[2]);
+ break;
+ case "E":
+ s = String.format("%s,%s,%s,%s\n", arr[0], arr[1], arr[2], arr[3]);
+ break;
+ case "D":
+ s = String.format("%s,%s,%s,%s\n", arr[0], arr[1], arr[2], arr[3]);
+ break;
+ default:
+ throw new InvalidCommandException();
+ }
+ return s;
+ }
+
+ /**
+ * Sets Status of Task to be done or not.
+ *
+ * @param checked String "0" to represent false, and "1" for true
+ */
+ public void setStatus(String checked) {
+ this.done = checked;
+ }
+
+ /**
+ * abstract object for child classes to return Task as a String Array of values
+ *
+ * @return String Array of values
+ */
+ public abstract String[] getStringArr();
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+
+ if (!(o instanceof Task)) {
+ return false;
+ }
+
+ Task c = (Task) o;
+
+ // Compare the data members and return accordingly
+ return description.equals(c.description);
+ }
+
+ @Override
+ public String toString() {
+ String icon = this.done.equals("1") ? "[✓]" : "[✗]";
+ return String.format("%s %s", icon, this.description);
+ }
+}
diff --git a/src/main/java/Duke/Tasks/Todo.java b/src/main/java/Duke/Tasks/Todo.java
new file mode 100644
index 0000000000..1e20fc77c3
--- /dev/null
+++ b/src/main/java/Duke/Tasks/Todo.java
@@ -0,0 +1,27 @@
+package duke.tasks;
+
+/**
+ * The type Todo.
+ */
+public class Todo extends Task {
+ /**
+ * Instantiates a new Todo.
+ *
+ * @param description the description
+ * @param done the done
+ */
+ public Todo(String description, String done) {
+ super(description, done);
+ }
+
+ @Override
+ public String[] getStringArr() {
+ String[] arr = {"T", super.done, super.description};
+ return arr;
+ }
+
+ @Override
+ public String toString() {
+ return "[T]" + super.toString();
+ }
+}
diff --git a/src/main/java/Duke/fxml/DialogBox.java b/src/main/java/Duke/fxml/DialogBox.java
new file mode 100644
index 0000000000..1d18a24d2e
--- /dev/null
+++ b/src/main/java/Duke/fxml/DialogBox.java
@@ -0,0 +1,99 @@
+package duke.fxml;
+
+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.Insets;
+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.Background;
+import javafx.scene.layout.BackgroundFill;
+import javafx.scene.layout.CornerRadii;
+import javafx.scene.layout.HBox;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
+
+/**
+ * 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, boolean isUser) {
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
+ fxmlLoader.setController(this);
+ fxmlLoader.setRoot(this);
+ fxmlLoader.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ //@@author lye-jw
+ //Reused from https://github.com/lye-jw/duke with minor modifications
+ dialog.setText(text);
+ displayPicture.setImage(img);
+
+ // Circle clipping starts from top left corner of image
+ displayPicture.setClip(new Circle(50, 50, 50));
+
+ Color color = isUser ? Color.LIGHTSKYBLUE : Color.KHAKI;
+
+ this.setBackground(
+ new Background(
+ new BackgroundFill(
+ color,
+ new CornerRadii(10.0),
+ new Insets(5, 5, 5, 5)
+ )
+ )
+ );
+ //@@author
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Gets user dialog.
+ *
+ * @param text the text
+ * @param img the img
+ * @return the user dialog
+ */
+ public static DialogBox getUserDialog(String text, Image img) {
+ return new DialogBox(text, img, true);
+ }
+
+ /**
+ * Gets duke dialog.
+ *
+ * @param text the text
+ * @param img the img
+ * @return the duke dialog
+ */
+ public static DialogBox getDukeDialog(String text, Image img) {
+ var db = new DialogBox(text, img, false);
+ db.flip();
+ return db;
+ }
+}
diff --git a/src/main/java/Duke/fxml/Main.java b/src/main/java/Duke/fxml/Main.java
new file mode 100644
index 0000000000..c75258e5f9
--- /dev/null
+++ b/src/main/java/Duke/fxml/Main.java
@@ -0,0 +1,32 @@
+package duke.fxml;
+
+import java.io.IOException;
+
+import duke.main.Duke;
+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("data/tasks.txt");
+
+ @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/Duke/fxml/MainWindow.java b/src/main/java/Duke/fxml/MainWindow.java
new file mode 100644
index 0000000000..5b3aa90c8b
--- /dev/null
+++ b/src/main/java/Duke/fxml/MainWindow.java
@@ -0,0 +1,68 @@
+package duke.fxml;
+
+import javafx.application.Platform;
+import javafx.beans.binding.Bindings;
+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 duke.main.Duke;
+
+/**
+ * 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"));
+
+ /**
+ * Initialize.
+ */
+ @FXML
+ public void initialize() {
+
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ sendButton.styleProperty().bind(Bindings.when(sendButton.hoverProperty())
+ .then("-fx-background-color: #45ACFD; -fx-text-fill: #FFFFFF")
+ .otherwise("-fx-background-color: #F6F6F6"));
+ }
+
+ /**
+ * Sets duke.
+ *
+ * @param d the d
+ */
+ 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();
+ }
+}
diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..30621e714a
--- /dev/null
+++ b/src/main/java/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: Duke.Main.Duke
+
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..d578f4e3b1
--- /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..5a02a51f63
--- /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/Main/DukeTest.java b/src/test/java/Duke/Main/DukeTest.java
new file mode 100644
index 0000000000..e6403bdbe5
--- /dev/null
+++ b/src/test/java/Duke/Main/DukeTest.java
@@ -0,0 +1,59 @@
+package Duke.Main;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.util.List;
+
+import Duke.Tasks.*;
+
+public class DukeTest {
+ @Test
+ public void StorageTest(){
+ Storage storage = new Storage("notapath");
+ try {
+ List lst = storage.getFileContents();
+ // Error should be thrown here
+ fail("Storage class not supposed to accept random paths");
+ } catch (Exception e) {
+ String errMsg = "java.io.FileNotFoundException: notapath (No such file or directory)";
+ assertEquals(e.toString(), errMsg);
+ }
+ }
+
+ @Test
+ public void ParserTest() {
+ assertEquals(
+ Parser.parseDateTime(Parser.strToDate("2019-04-18 1800")),
+ "Apr 18 2019, 6.00PM"
+ );
+ }
+
+ @Test
+ public void TaskLiskTest() {
+ Storage storage = new Storage("./data/tasks.txt");
+ TaskList tasks = new TaskList(storage);
+ String[] todo1 = {"T", "0", "write book"};
+ String[] event2 = {"E", "0", "borrow book", "2019-04-18 1300"};
+ String[] deadline3 = {"D", "0", "return book", "2019-04-19 1800"};
+ try {
+ tasks.addTask(todo1);
+ tasks.addTask(event2);
+ tasks.addTask(deadline3);
+
+ tasks.completeTask(1);
+ tasks.completeTask(2);
+ tasks.completeTask(3);
+
+ tasks.deleteTask(tasks.getSize());
+ tasks.deleteTask(tasks.getSize());
+ tasks.deleteTask(tasks.getSize());
+ assertTrue(true);
+ } catch (Exception e) {
+// System.out.println("Working Directory = " + System.getProperty("user.dir"));
+ fail("One of the TaskList has failed");
+ }
+ }
+
+
+}
diff --git a/src/test/java/data/tasks.txt b/src/test/java/data/tasks.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT
index 657e74f6e7..a3ff30dcf2 100644
--- a/text-ui-test/EXPECTED.TXT
+++ b/text-ui-test/EXPECTED.TXT
@@ -1,7 +1,84 @@
-Hello from
- ____ _
-| _ \ _ _| | _____
-| | | | | | | |/ / _ \
-| |_| | |_| | < __/
-|____/ \__,_|_|\_\___|
-
+____________________________________________________________
+Hello! I am your mother!
+What can I do for you son!
+____________________________________________________________
+____________________________________________________________
+Unknown command! Please insert the task type first before
+typing in your task!
+____________________________________________________________
+____________________________________________________________
+You have no tasks left! Good job my child!
+____________________________________________________________
+____________________________________________________________
+Please insert a task!
+____________________________________________________________
+____________________________________________________________
+ Got it. I've added this task:
+ [T][✘] yeet
+ Now you have 1 task in the list.
+____________________________________________________________
+____________________________________________________________
+ Here is the task in your list:
+ 1.[T][✘] yeet
+____________________________________________________________
+____________________________________________________________
+Please insert a task!
+____________________________________________________________
+____________________________________________________________
+Please input a date!
+____________________________________________________________
+____________________________________________________________
+ Got it. I've added this task:
+ [D][✘] haha (by: dab)
+ Now you have 2 tasks in the list.
+____________________________________________________________
+____________________________________________________________
+Please insert a task!
+____________________________________________________________
+____________________________________________________________
+Please input a date!
+____________________________________________________________
+____________________________________________________________
+ Got it. I've added this task:
+ [E][✘] huhu (at: yeet)
+ Now you have 3 tasks in the list.
+____________________________________________________________
+____________________________________________________________
+ Here are the tasks in your list:
+ 1.[T][✘] yeet
+ 2.[D][✘] haha (by: dab)
+ 3.[E][✘] huhu (at: yeet)
+____________________________________________________________
+____________________________________________________________
+Uh oh! That number looks like it is out of range.
+Check again!
+____________________________________________________________
+____________________________________________________________
+Great job son! I'll mark 'yeet' as done for you. ^^
+____________________________________________________________
+____________________________________________________________
+Uh oh! That number looks like it is out of range.
+Check again!
+____________________________________________________________
+____________________________________________________________
+Sorry! You have already completed 'yeet'.
+____________________________________________________________
+____________________________________________________________
+ Here are the tasks in your list:
+ 1.[T][✓] yeet
+ 2.[D][✘] haha (by: dab)
+ 3.[E][✘] huhu (at: yeet)
+____________________________________________________________
+____________________________________________________________
+ Noted. I've removed this task:
+ [T][✓] yeet
+ Now you have 2 tasks in the list.
+____________________________________________________________
+____________________________________________________________
+ Here are the tasks in your list:
+ 1.[D][✘] haha (by: dab)
+ 2.[E][✘] huhu (at: yeet)
+____________________________________________________________
+____________________________________________________________
+Goodbye my child!
+____________________________________________________________
\ No newline at end of file
diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt
index e69de29bb2..a9e12e1e32 100644
--- a/text-ui-test/input.txt
+++ b/text-ui-test/input.txt
@@ -0,0 +1,20 @@
+dab
+list
+todo
+todo yeet
+list
+deadline
+deadline hehe
+deadline haha /by dab
+event /at
+event hoho
+event huhu /at yeet
+list
+done -1
+done 1
+done 4
+done 01
+list
+delete 1
+list
+bye
\ No newline at end of file
diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat
index d0facc6310..e4e1748e19 100644
--- a/text-ui-test/runtest.bat
+++ b/text-ui-test/runtest.bat
@@ -1,13 +1,15 @@
@ECHO OFF
+SET MY_PATH="C:\Users\ambro\Downloads\nus\~y2s1\cs2103\ip"
+
REM create bin directory if it doesn't exist
-if not exist ..\bin mkdir ..\bin
+if not exist "%MY_PATH%\bin" mkdir "%MY_PATH%\bin"
REM delete output from previous run
del ACTUAL.TXT
REM compile the code into the bin folder
-javac -cp ..\src -Xlint:none -d ..\bin ..\src\main\java\Duke.java
+javac -cp "%MY_PATH%\src\main\java" -Xlint:none -d "%MY_PATH%\bin" "%MY_PATH%\src\main\java\duke.main.Duke.java"
IF ERRORLEVEL 1 (
echo ********** BUILD FAILURE **********
exit /b 1
@@ -15,7 +17,7 @@ IF ERRORLEVEL 1 (
REM no error here, errorlevel == 0
REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
-java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
+java -classpath "%MY_PATH%\bin" duke.main.Duke < input.txt > ACTUAL.TXT
REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT
diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh
old mode 100644
new mode 100755