diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..a3605a442f
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,61 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'checkstyle'
+ id 'com.github.johnrengelman.shadow' version '5.1.0'
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ String javaFxVersion = '11'
+ 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'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
+}
+
+test {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed"
+
+ showExceptions true
+ exceptionFormat "full"
+ showCauses true
+ showStackTraces true
+ showStandardStreams = false
+ }
+}
+
+application {
+ mainClassName = "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..6d69fcf10b
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,398 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
new file mode 100644
index 0000000000..7fa38b37cf
--- /dev/null
+++ b/config/checkstyle/suppressions.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/README.md b/docs/README.md
index fd44069597..54b002757b 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,20 +1,140 @@
# User Guide
## Features
+* Add a task to do: `todo`
+* Add a task with a deadline: `deadline`
+* Add an event: `event`
+* Remove a task: `remove`
+* Mark task as done: `done`
+* Find task by keyword: `find`
+* List tasks: `list`
+* Exit the program: `bye`
+
+
+### Add a task to do: todo
+Adds a `todo` with the specified description to the task list.
+
+Format: `todo TASK`
+
+Example: `todo walk the dog`
+
+Expected Outcome:
+```
+Got it. I've added this task:
+ [T][x] walk the dog
+Now you have 3 tasks in the list
+```
+
+### Add a task with a deadline: deadline
+Adds a `deadline` with the specified description to the task list.
+
+Format: `deadline TASK /by DATE`
+* DATE format is in **YYYY-MM-DD**
+
+Example: deadline complete individual project /by 2020-09-18`
+
+Expected Outcome:
+```
+Got it. I've added this task:
+ [D][x] complete individual project (Sep 18 2020)
+ Now you have 4 tasks in the list
+```
+
+### Add an event: event
+Adds an `event` with the specified description to the task list.
+
+Format: `event TASK /at DATE`
+* DATE format is in **YYYY-MM-DD**
+
+Example: `event music festival /at 2020-09-20`
+
+Expected Outcome:
+```
+Got it. I've added this task:
+ [E][x] music festival (Sep 20 2020)
+ Now you have 5 tasks in the list
+```
+### Remove a task: remove
+Removes a task from the task list.
+
+Format: `remove INDEX`
+* Removes the task at the specified index
+* The index refers to the index number of the task as shown in the list
+* The index **must be a positive integer** 1,2,3
+
+Example: `remove 2`
+
+Expected Outcome:
+```
+Noted. I've removed this task:
+ [T][x] read book
+ Now you have 4 tasks in the list.
+```
+
+### Mark task as done: done
+Marks a task as done in the task list.
+
+Format: `done INDEX`
+* Marks the task at the specified index as done (using a tick)
+* The index refers to the index number of the task as shown in the list
+* The index **must be a positive integer** 1,2,3
+
+Example: `done 2`
+
+Expected Outcome:
+```
+Nice! I've marked this task as done:
+ [/] walk the dog
+```
+
+### Find task by keyword: find
+Finds a task in the task list by keyword.
+
+Format: `find KEYWORD`
+
+Example: `find music`
+
+Expected Outcome:
+```
+Tasks Found:
+ 5. [E][x] music festival (Sep 20 2020)
+```
+
+### List tasks: list
+Lists the current task list.
+
+Format: `list`
+
+Expected Outcome:
+```
+Here are the tasks in your list:
+ 1. [T][x] complete project
+```
+
+### Exit the program: bye
+Exits the program.
+
+Format: `bye`
+
+Expected Outcome:
+`Bye. Hope to see you again soon!`
+
+### Saving data
+Task List data is automatically saved in the harddisk after any command that changes its data.
+There is no need to save manually
+
+
+
+
+
+
+
+
-### Feature 1
-Description of feature.
-## Usage
-### `Keyword` - Describe action
-Describe action and its outcome.
-Example of usage:
-`keyword (optional arguments)`
-Expected outcome:
-`outcome`
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..eecd6f200b
Binary files /dev/null and b/docs/Ui.png differ
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..f3d88b1c2f
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..0d88a99e51
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sun Aug 30 15:28:22 SGT 2020
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
new file mode 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/listStore.ser b/listStore.ser
new file mode 100644
index 0000000000..40e85cac66
Binary files /dev/null and b/listStore.ser differ
diff --git a/src/main/java/DialogBox.java b/src/main/java/DialogBox.java
new file mode 100644
index 0000000000..b0591d48b1
--- /dev/null
+++ b/src/main/java/DialogBox.java
@@ -0,0 +1,81 @@
+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;
+import javafx.scene.shape.Circle;
+import javafx.geometry.Insets;
+
+/**
+ * An example of a custom control using FXML.
+ * This control represents a dialog box consisting of an ImageView to represent the speaker's face and a label
+ * containing text from the speaker.
+ */
+public class DialogBox extends HBox {
+ @FXML
+ private Label dialog;
+ @FXML
+ private ImageView displayPicture;
+
+ private DialogBox(String text, Image img) {
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
+ fxmlLoader.setController(this);
+ fxmlLoader.setRoot(this);
+ fxmlLoader.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ Circle circle = new Circle();
+ circle.setCenterX(55);
+ circle.setCenterY(50);
+ circle.setRadius(40);
+
+ displayPicture.setClip(circle);
+ dialog.setStyle("-fx-background-color: yellow;" + "-fx-background-radius: 20;"
+ + "-fx-min-width: 50; -fx-end-margin: 20");
+ dialog.setPadding(new Insets(12));
+
+ 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);
+
+ Circle circle = new Circle();
+ circle.setCenterX(40);
+ circle.setCenterY(25);
+ circle.setRadius(30);
+
+ displayPicture.setClip(circle);
+ dialog.setStyle("-fx-background-color: pink;" + "-fx-background-radius: 20;"
+ + "-fx-min-width: 250; -fx-end-margin: 20");
+ dialog.setPadding(new Insets(12));
+
+ }
+
+ public static DialogBox getUserDialog(String text, Image img) {
+ return new DialogBox(text, img);
+ }
+
+ public static DialogBox getDukeDialog(String text, Image img) {
+ var db = new DialogBox(text, img);
+ db.flip();
+ return db;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java
index 5d313334cc..c90e8e8da0 100644
--- a/src/main/java/Duke.java
+++ b/src/main/java/Duke.java
@@ -1,10 +1,593 @@
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.ScrollPane;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.VBox;
+
+import java.io.*;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+
+/**
+ * Duke is a program to keep track of and organise tasks, including todo tasks, event tasks, and deadline tasks.
+ *
+ * @author Yan Lyn
+ */
public class Duke {
- public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
+
+ private static Storage storage;
+ private TaskList inputs;
+ private UI ui;
+ private ScrollPane scrollPane;
+ private VBox dialogContainer;
+ private TextField userInput;
+ private Button sendButton;
+ private Scene scene;
+
+ /**
+ * getResponse returns Duke's response to be shown on the user interface.
+ *
+ * @throws DukeException
+ */
+ public String getResponse(String input) throws DukeException {
+ return new Duke("listStore.ser").run(input);
+ }
+
+ /**
+ * Duke constructor constructs Duke object, while initializing 'ui', 'storage' and 'inputs' variables.
+ * The 'inputs' TaskList is retrieved from the file specified by the filepath.
+ *
+ * @param filepath
+ */
+ public Duke(String filepath) {
+ assert filepath == "listStore.ser";
+ ui = new UI();
+ storage = new Storage(filepath);
+ try {
+ inputs = new TaskList(storage.readFile());
+ } catch (DukeException e) {
+ ui.showLoadingError();
+ inputs = new TaskList();
+ }
+ }
+
+ //Empty Constructor
+ public Duke() {
+ }
+
+ /**
+ * The run() method runs the program by initializing a parser object to deal with making sense of user command
+ * and running the parse() method on the parser object.
+ * The run() method directly returns the string "Bye. Hope to see you again soon!" if user input is "bye".
+ *
+ * @return Duke's output in a string
+ * @throws DukeException in case of DukeException when running parse() method on the parser object
+ */
+ public String run(String input) throws DukeException {
+ while (true) {
+ String nextLine = input;
+ Parser parser = new Parser(nextLine, inputs);
+ if (nextLine.equals("bye")) {
+ return ("Bye. Hope to see you again soon!");
+ }
+ return parser.parse();
+ }
+ }
+
+<<<<<<< HEAD
+ /**
+ * Parser class deals with making sense of user command.
+ */
+ public static class Parser {
+ private final String userInput;
+ private final TaskList savedTaskList;
+=======
+ public static void main (String[]args) throws DukeException {
+ new Duke("listStore.ser").run("Hello");
+ }
+
+>>>>>>> branch-A-Assertions
+
+ Parser(String nextLine, TaskList inputs) {
+ this.userInput = nextLine;
+ this.savedTaskList = inputs;
+ }
+
+ /**
+ * Runs different methods on the TaskList based on user command.
+ *
+ * @throws DukeException if user command is not recognised or if methods in TaskList throw DukeException
+ */
+ String parse() throws DukeException {
+ try {
+ if (userInput.startsWith("done")) {
+ return savedTaskList.taskDone(userInput);
+ } else if (userInput.startsWith("remove")) {
+ return savedTaskList.removeTask(userInput);
+ } else if (userInput.startsWith("todo")) {
+ return savedTaskList.addTodoTask(userInput);
+ } else if (userInput.startsWith("deadline")) {
+ return savedTaskList.addDeadlineTask(userInput);
+ } else if (userInput.startsWith("event")) {
+ return savedTaskList.addEventTask(userInput);
+ } else if (userInput.startsWith("find")) {
+ return savedTaskList.findTask(userInput);
+ } else if (userInput.equals("list")) {
+ return savedTaskList.printList();
+ } else {
+ throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
+ }
+ } catch (DukeException e) {
+ System.out.println(e.msg);
+ return e.msg;
+ }
+ }
+ }
+
+ /**
+ * Input class represents input from the user in the form of tasks.
+ */
+ public static class Input implements Serializable {
+ boolean done = false;
+ String content;
+ String id;
+ LocalDate time;
+ String printTime;
+
+ Input(String content) {
+ this.content = content;
+ boolean done = false;
+ }
+
+ Input(boolean done, String content) {
+ this.done = done;
+ this.content = content;
+ }
+
+ /**
+ * taskDone() method marks task as done by setting boolean 'done' as true.
+ */
+ public void taskDone() {
+ System.out.println("check");
+ this.done = true;
+ }
+ }
+
+ public static class Todo extends Input {
+
+ Todo(String content) {
+ super(content);
+ this.id = "[T]";
+ this.time = null;
+ this.printTime = "";
+ }
+
+ Todo(boolean done, String content) {
+ super(done, content);
+ this.id = "[T]";
+ this.time = null;
+ this.printTime = "";
+ }
+ }
+
+ public static class Deadline extends Input {
+
+ /**
+ * Constructor for Deadline Object.
+ * Converts date specified by the user from a string to a LocalDate object, under the 'time' attribute.
+ * Formats LocalDate and converts it back to a string for printing, under the 'printTime' attribute.
+ *
+ * @param content
+ * @param deadlineTime
+ */
+ Deadline(String content, String deadlineTime) {
+ super(content);
+ this.time = LocalDate.parse(deadlineTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[D]";
+ this.printTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+
+ Deadline(boolean done, String content, String deadlineTime) {
+ super(done, content);
+ this.time = LocalDate.parse(deadlineTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[D]";
+ this.printTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+ }
+
+ public static class Event extends Input {
+
+ /**
+ * Constructor for Event Object.
+ * Converts date specified by the user from a string to a LocalDate object, under the 'time' attribute.
+ * Formats LocalDate and converts it back to a string for printing, under the 'printTime' attribute.
+ *
+ * @param content
+ * @param eventTime
+ */
+ Event(String content, String eventTime) {
+ super(content);
+ this.time = LocalDate.parse(eventTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[E]";
+ this.printTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+
+ Event(boolean done, String content, String eventTime) {
+ super(done, content);
+ this.time = LocalDate.parse(eventTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[E]";
+ this.printTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+ }
+
+ /**
+ * DukeException class which inherits directly from Exception class.
+ */
+ public static class DukeException extends Exception {
+ protected String msg;
+
+ DukeException(String msg) {
+ this.msg = msg;
+ }
+ }
+
+ /**
+ * Storage Class deals with saving and retrieving data from a hard disk.
+ */
+ public static class Storage {
+ private String filepath;
+
+ Storage(String filepath) {
+ this.filepath = filepath;
+ }
+
+ /**
+<<<<<<< HEAD
+ * Saves TaskList in a file which is based on the filepath in the Storage Class.
+=======
+ * Saves tasks in file specified by the filepath.
+>>>>>>> branch-A-Assertions
+ *
+ * @param list of input tasks to be saved
+ * @catch IOException
+ */
+ void writeToFile(List list) {
+ try {
+ FileOutputStream writeData = new FileOutputStream(filepath);
+ ObjectOutputStream writeStream = new ObjectOutputStream(writeData);
+ writeStream.writeObject(list);
+ writeStream.flush();
+ writeStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Retrieves TaskList from a file based on the filepath in the Storage Class.
+ *
+ * @returns TaskList from file
+ * @catch FileNotFoundException if file does not exist, creates a new arraylist
+ * @catch IOException and ClassNotFoundException, returns null
+ */
+ List readFile() {
+ try {
+ FileInputStream readData = new FileInputStream(filepath);
+ ObjectInputStream readStream = new ObjectInputStream(readData);
+ Object obj = readStream.readObject();
+ if (obj != null) {
+ List inputList = (List) obj;
+ readStream.close();
+ return inputList;
+ } else {
+ return null;
+ }
+ } catch (FileNotFoundException e) {
+ return new ArrayList<>();
+ } catch (IOException | ClassNotFoundException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+
+ /**
+ * TaskList class represents the list of input tasks.
+ */
+ public static class TaskList {
+ List inputs;
+
+ TaskList() {
+ this.inputs = new ArrayList();
+ }
+
+ TaskList(List inputs) throws DukeException {
+ try {
+ this.inputs = inputs;
+ } catch (Exception e) {
+ throw new DukeException("Error making task!");
+ }
+ }
+
+ /**
+<<<<<<< HEAD
+ * Identifies task specified by the user and invokes taskDone() method from Input class to mark task as done.
+ * Saves the resulting list to a hard disk.
+=======
+ * Marks task, as specified by user, as done.
+>>>>>>> branch-A-Assertions
+ *
+ * @return A string representing Duke's response to be shown to user
+ * @param nextLine representing user input
+ * @throws DukeException if user does not specify which task done, or if task specified is not in list
+ */
+ String taskDone(String nextLine) throws DukeException {
+ if (nextLine.equals("done") || nextLine.equals("done ")) {
+ throw new DukeException("OOPS!!! The description of done cannot be empty.");
+ }
+ int numTaskDone = Integer.valueOf(nextLine.substring(5));
+ if (numTaskDone > inputs.size()) {
+ throw new DukeException("OOPS!!! Task does not exist.");
+ } else if (inputs.size() == 0) {
+ throw new DukeException("OOPS!!! List is empty!");
+ } else {
+ Input inputType = inputs.get(numTaskDone - 1);
+ inputType.taskDone();
+ storage.writeToFile(inputs);
+ return ("Nice! I've marked this task as done:" + "\n" + "[/] " + inputType.content + " " + inputType.printTime);
+ }
+ }
+
+ /**
+<<<<<<< HEAD
+ * Identifies task specified by the user and removes the task from the list.
+ * Saves the resulting list to the hard disk.
+=======
+ * removes task, as specified by the user, from list.
+>>>>>>> branch-A-Assertions
+ *
+ * @return A string representing Duke's response to be shown to user
+ * @param nextLine, represents user input
+ * @throws DukeException if user does not specify which task to remove or task is not in list
+ */
+ String removeTask(String nextLine) throws DukeException {
+ if (nextLine.equals("remove") || nextLine.equals("remove ")) {
+ throw new DukeException("OOPS!!! The description of remove cannot be empty");
+ }
+ int numTaskDone = Integer.valueOf(nextLine.substring(7));
+ if (numTaskDone > inputs.size()) {
+ throw new DukeException("OOPS!!! Task does not exist.");
+ }
+ Input inputType = inputs.get(numTaskDone - 1);
+ inputs.remove(numTaskDone - 1);
+ storage.writeToFile(inputs);
+ if (inputType.done) {
+ return "Noted. I've removed this task:" + "\n" + inputType.id + "[/] " + inputType.content
+ + inputType.printTime + "\n" + "Now you have " + inputs.size() + " tasks in the list.";
+ } else {
+ return "Noted. I've removed this task:" + "\n" + inputType.id + "[x] " + inputType.content
+ + inputType.printTime + "\n" + "Now you have " + inputs.size() + " tasks in the list.";
+ }
+ }
+
+ /**
+<<<<<<< HEAD
+ * Adds a to-do object to the list based on user input.
+ * Saves the resulting list to a hard disk.
+=======
+ * Adds a to-do object to the list, and saves the list to hard disk.
+>>>>>>> branch-A-Assertions
+ *
+ * @return A string representing Duke's response to be shown to user
+ * @param nextLine, represents user input
+ * @throws DukeException if user does not specify task to-do
+ */
+ String addTodoTask(String nextLine) throws DukeException {
+ if (nextLine.equals("todo") || nextLine.equals("todo ")) {
+ throw new DukeException("OOPS!!! The description of a todo cannot be empty.");
+ }
+ Todo todo = new Todo(nextLine.substring(5));
+ if (taskExist(todo.content, null)) {
+ return "Could not add task. Task already exists!";
+ }
+ inputs.add(todo);
+ int count = inputs.size();
+ storage.writeToFile(inputs);
+ assert inputs != null;
+ return "Got it. I've added this task: \n" + " [T][x] " + todo.content
+ + "\n Now you have " + count + " tasks in the list";
+ }
+
+ /**
+ * Adds a deadline object to the list based on user input.
+ * Saves the resulting list to a hard disk.
+ *
+ * @return A string representing Duke's response to be shown to user
+ * @param nextLine, represents user input
+ * @throws DukeException if user does not specify deadline task
+ */
+ String addDeadlineTask(String nextLine) throws DukeException {
+ try {
+ if (nextLine.equals("deadline") || nextLine.equals("deadline ")) {
+ throw new DukeException("OOPS!!! The description of a deadline cannot be empty.");
+ }
+ int charLoc = nextLine.indexOf("/by");
+ Deadline deadline = new Deadline(nextLine.substring(9, charLoc), nextLine.substring(charLoc + 4));
+ if (taskExist(deadline.content, deadline.time)) {
+ return "Could not add task. Task already exists!";
+ }
+ inputs.add(deadline);
+ int count = inputs.size();
+ storage.writeToFile(inputs);
+ assert inputs != null;
+ return ("Got it. I've added this task: \n" + " [D][x] " + deadline.content
+ + deadline.printTime + "\n Now you have " + count + " tasks in the list");
+ } catch (java.time.format.DateTimeParseException e) {
+ return "Please provide proper date format!";
+ }
+ }
+
+ /**
+<<<<<<< HEAD
+ * Adds an event object to the list based on user input.
+ * Saves the resulting list to a hard disk.
+=======
+ * Adds an event object to the list, and saves the list to hard disk.
+>>>>>>> branch-A-Assertions
+ *
+ * @return A string representing Duke's response to be shown to user
+ * @param nextLine, represents user input
+ * @throws DukeException if user does not specify event task
+ */
+ String addEventTask(String nextLine) throws DukeException {
+ try {
+ if (nextLine.equals("event") || nextLine.equals("event ")) {
+ throw new DukeException("OOPS!!! The description of an event cannot be empty.");
+ }
+ int charLoc = nextLine.indexOf("/at");
+ Event event = new Event(nextLine.substring(6, charLoc), nextLine.substring(charLoc + 4));
+ if (taskExist(event.content, event.time)) {
+ return "Could not add task. Task already exists!";
+ }
+ inputs.add(event);
+ int count = inputs.size();
+ storage.writeToFile(inputs);
+ assert inputs != null;
+ return ("Got it. I've added this task: \n" + " [E][x] " + event.content
+ + event.printTime + "\n Now you have " + count + " tasks in the list");
+ } catch (java.time.format.DateTimeParseException e) {
+ return "Please provide proper date format!";
+ }
+<<<<<<< HEAD
+=======
+ int charLoc = nextLine.indexOf("/at");
+ Event event = new Event(nextLine.substring(6, charLoc), nextLine.substring(charLoc + 4));
+ inputs.add(event);
+ int count = inputs.size();
+ storage.writeToFile(inputs);
+ assert inputs != null;
+ return ("Got it. I've added this task: \n" + " [E][x] " + event.content
+ + event.printTime + "\n Now you have " + count + " tasks in the list");
+>>>>>>> branch-A-Assertions
+ }
+
+ /**
+ * Find tasks which contains keyword specified by user.
+ *
+ * @return A list of tasks containing the keyword
+ * @param nextLine, represents user input
+ * @throws DukeException if user does not specify task to find
+ */
+ String findTask(String nextLine) throws DukeException {
+ if (nextLine.equals("find") || nextLine.equals("find ")) {
+ throw new DukeException("OOPS!!! The description of find cannot be empty");
+ }
+ String keyword = nextLine.substring(5);
+ int len = inputs.size();
+ String stringList = "Tasks Found: \n";
+ for (int i = 0; i < len; i++) {
+ Input input = inputs.get(i);
+ if (input.content.contains(keyword)) {
+ stringList += printTask(input, i);
+ }
+ }
+ return stringList;
+ }
+
+ /**
+ * Prints a list of the tasks in the TaskList.
+ *
+ * @return list of tasks in TaskList
+ */
+ String printList() {
+ if (this.inputs.size() == 0) {
+ return "No tasks in list";
+ } else {
+ int len = this.inputs.size();
+ String stringList = "Here are the tasks in your list: \n";
+ for (int i = 0; i <= len-1; i++) {
+ Input input = this.inputs.get(i);
+ stringList += printTask(input, i);
+ }
+ return stringList;
+ }
+ }
+
+ /**
+ * Prints input task to a string, to be shown to the user as Duke's response.
+ * Prints string with '[/]' if input task is done, otherwise prints string with '[x]'.
+ *
+ * @param input, which represents the input task to print to string.
+ * @param i, which is the index of the task in the list
+ * @return string to be shown to user
+ */
+ String printTask(Input input, int i) {
+ if (input.done) {
+ return ((i+1) + ". " + input.id + "[/] " + input.content + input.printTime + "\n");
+ } else {
+ return ((i+1) + ". " + input.id + "[x] " + input.content + input.printTime + "\n");
+ }
+ }
+
+ /**
+ * Checks if task already exists to avoid duplicates.
+ * @param taskContent
+ * @return true if task exists, false if task does not exist
+ */
+ boolean taskExist(String taskContent, LocalDate taskDate) {
+ int len = inputs.size();
+ for(int i = 0; i < len; i++) {
+ Input taskFromList = inputs.get(i);
+ if (taskFromList.content.contains(taskContent) && taskDateMatch(taskFromList, taskDate)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Checks if the date of two tasks are the same.
+ * @param task
+ * @param taskDate
+ * @return true if the date of both tasks matches or the second task does not have a date
+ */
+ boolean taskDateMatch(Input task, LocalDate taskDate) {
+ if (taskDate == null) {
+ return true;
+ }
+ if (task.time == null) {
+ return false;
+ } else if (task.time.isEqual(taskDate)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ }
+
+ /**
+ * UI class deals with the User Input.
+ */
+ public static class UI {
+
+<<<<<<< HEAD
+ /**
+ * Prints 'Loading Error!' if DukeException is caught while constructing Duke Object.
+=======
+ /**
+ * Guides the TaskList based on user command.
+ *
+ * @throws DukeException
+>>>>>>> branch-A-Assertions
+ */
+ void showLoadingError() {
+ System.out.println("Loading Error!");
+ }
+
+
}
}
diff --git a/src/main/java/Duke.java.orig b/src/main/java/Duke.java.orig
new file mode 100644
index 0000000000..cf162fbc64
--- /dev/null
+++ b/src/main/java/Duke.java.orig
@@ -0,0 +1,382 @@
+import java.util.Date;
+import java.util.Scanner;
+import java.util.ArrayList;
+import java.util.List;
+import java.io.*;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
+
+public class Duke {
+
+ private static Storage storage;
+ private TaskList inputs;
+ private UI ui;
+
+ public Duke(String filepath) {
+ ui = new UI();
+ storage = new Storage(filepath);
+ try {
+ inputs = new TaskList(storage.readFile());
+ } catch (DukeException e) {
+ ui.showLoadingError();
+ inputs = new TaskList();
+ }
+ }
+
+ public void run() throws DukeException {
+ while (true) {
+ String nextLine = ui.readInput();
+ Parser parser = new Parser(nextLine, inputs);
+ if (nextLine.equals("bye")) {
+ System.out.println("Bye. Hope to see you again soon!");
+ break;
+ }
+ parser.parse();
+ }
+ }
+
+ public static void main (String[]args) throws DukeException {
+ new Duke("listStore.ser").run();
+ }
+
+ public static class Input implements Serializable {
+ boolean isDone;
+ String content;
+ String id;
+ LocalDate time;
+ String printedTime;
+
+ Input(String content) {
+ this.content = content;
+ boolean done = false;
+ }
+
+ Input(boolean done, String content) {
+ this.isDone = done;
+ this.content = content;
+ }
+
+ public void taskDone() {
+ this.isDone = true;
+ }
+ }
+
+ public static class Todo extends Input {
+
+ Todo(String content) {
+ super(content);
+ this.id = "[T]";
+ this.time = null;
+ this.printedTime = "";
+ }
+
+ Todo(boolean done, String content) {
+ super(done, content);
+ this.id = "[T]";
+ this.time = null;
+ this.printedTime = "";
+ }
+ }
+
+ public static class Deadline extends Input {
+
+ Deadline(String content, String deadlineTime) {
+ super(content);
+ this.time = LocalDate.parse(deadlineTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[D]";
+ this.printedTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+
+ Deadline(boolean done, String content, String deadlineTime) {
+ super(done, content);
+ this.time = LocalDate.parse(deadlineTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[D]";
+ this.printedTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+ }
+
+ public static class Event extends Input {
+
+ Event(String content, String eventTime) {
+ super(content);
+ this.time = LocalDate.parse(eventTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[E]";
+ this.printedTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+
+ Event(boolean done, String content, String eventTime) {
+ super(done, content);
+ this.time = LocalDate.parse(eventTime, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+ this.id = "[E]";
+ this.printedTime = "(" + time.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ }
+ }
+
+
+ public static class DukeException extends Exception {
+ String msg;
+
+ DukeException(String msg) {
+ this.msg = msg;
+ }
+ }
+
+ public static class Storage {
+ String filepath;
+
+ Storage(String filepath) {
+ this.filepath = filepath;
+ }
+
+ void writeToFile(List list) {
+ try {
+ FileOutputStream writeData = new FileOutputStream(filepath);
+ ObjectOutputStream writeStream = new ObjectOutputStream(writeData);
+ writeStream.writeObject(list);
+ writeStream.flush();
+ writeStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ List readFile() {
+ try {
+ FileInputStream readData = new FileInputStream(filepath);
+ ObjectInputStream readStream = new ObjectInputStream(readData);
+ Object obj = readStream.readObject();
+ if (obj != null) {
+ List inputList = (List) obj;
+ readStream.close();
+ return inputList;
+ } else {
+ return null;
+ }
+ } catch (FileNotFoundException e) {
+ return new ArrayList<>();
+ } catch (IOException | ClassNotFoundException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ }
+
+
+ public static class TaskList {
+ List inputs;
+
+ TaskList() {
+ this.inputs = new ArrayList();
+ }
+
+ TaskList(List inputs) throws DukeException {
+ try {
+ this.inputs = inputs;
+ } catch (Exception e) {
+ throw new DukeException("Error making task!");
+ }
+ }
+
+ void taskDone(String nextLine) throws DukeException {
+ if (nextLine.equals("done") || nextLine.equals("done ")) {
+ throw new DukeException("OOPS!!! The description of done cannot be empty.");
+ }
+ int numTaskDone = Integer.valueOf(nextLine.substring(5));
+ if (numTaskDone > inputs.size()) {
+ throw new DukeException("OOPS!!! Task does not exist.");
+ }
+ System.out.println("Nice! I've marked this task as done:");
+ Input inputType = inputs.get(numTaskDone - 1);
+ inputType.taskDone();
+ System.out.println("[/] " + inputType.content + " " + inputType.printedTime);
+ }
+
+ void taskRemove(String nextLine) throws DukeException {
+ if (nextLine.equals("remove") || nextLine.equals("remove ")) {
+ throw new DukeException("OOPS!!! The description of remove cannot be empty");
+ }
+ int numTaskDone = Integer.valueOf(nextLine.substring(7));
+ if (numTaskDone > inputs.size()) {
+ throw new DukeException("OOPS!!! Task does not exist.");
+ }
+ System.out.println("Noted. I've removed this task:");
+ Input inputType = inputs.get(numTaskDone - 1);
+ if (inputType.isDone) {
+ System.out.println(" " + inputType.id + "[/] " + inputType.content + inputType.printedTime);
+ } else {
+ System.out.println(" " + inputType.id + "[x] " + inputType.content + inputType.printedTime);
+ }
+<<<<<<< HEAD
+ inputs.remove(numTaskDone - 1);
+ System.out.println("Now you have " + inputs.size() + " tasks in the list.");
+ storage.writeToFile(inputs);
+=======
+
+ void taskFind(String nextLine) throws DukeException {
+ if (nextLine.equals("find") || nextLine.equals("find ")) {
+ throw new DukeException("OOPS!!! The description of find cannot be empty");
+ }
+ String keyword = nextLine.substring(5);
+ int len = inputs.size();
+ for(int i = 0; i < len; i++) {
+ Input input = inputs.get(i);
+ if (input.content.contains(keyword)) {
+ if (input.done) {
+ System.out.println((i+1) + ". " + input.id + "[/] " + input.content +
+ input.printTime);
+ } else {
+ System.out.println((i+1) + ". " + input.id + "[x] " + input.content +
+ input.printTime);
+ }
+ }
+ }
+ }
+
+>>>>>>> branch-Level-9
+ }
+
+ void taskTodo(String nextLine) throws DukeException {
+ if (nextLine.equals("todo") || nextLine.equals("todo ")) {
+ throw new DukeException("OOPS!!! The description of a todo cannot be empty.");
+ }
+ Todo todo = new Todo(nextLine.substring(5));
+ inputs.add(todo);
+ int count = inputs.size();
+ System.out.println("Got it. I've added this task: \n" + " [T][x] " + todo.content +
+ "\n Now you have " + count + " tasks in the list");
+ storage.writeToFile(inputs);
+ }
+
+ void taskDeadline(String nextLine) throws DukeException {
+ if (nextLine.equals("deadline") || nextLine.equals("deadline ")) {
+ throw new DukeException("OOPS!!! The description of a deadline cannot be empty.");
+ }
+ int charLoc = nextLine.indexOf("/by");
+ Deadline deadline = new Deadline(nextLine.substring(9, charLoc), nextLine.substring(charLoc + 4));
+ inputs.add(deadline);
+ int count = inputs.size();
+ System.out.println("Got it. I've added this task: \n" + " [D][x] " + deadline.content +
+ deadline.printedTime + "\n Now you have " + count + " tasks in the list");
+ storage.writeToFile(inputs);
+ }
+
+ void taskEvent(String nextLine) throws DukeException {
+ if (nextLine.equals("event") || nextLine.equals("event ")) {
+ throw new DukeException("OOPS!!! The description of an event cannot be empty.");
+ }
+ int charLoc = nextLine.indexOf("/at");
+ Event event = new Event(nextLine.substring(6, charLoc), nextLine.substring(charLoc + 4));
+ inputs.add(event);
+ int count = inputs.size();
+ System.out.println("Got it. I've added this task: \n" + " [E][x] " + event.content +
+ event.printedTime + "\n Now you have " + count + " tasks in the list");
+ storage.writeToFile(inputs);
+ }
+ }
+
+ public static class UI {
+ Scanner sc = new Scanner(System.in);
+
+ UI() {
+ String logo = " ____ _ \n"
+ + "| _ \\ _ _| | _____ \n"
+ + "| | | | | | | |/ / _ \\\n"
+ + "| |_| | |_| | < __/\n"
+ + "|____/ \\__,_|_|\\_\\___|\n";
+ System.out.println("Hello from\n" + logo);
+ System.out.println("Hello! I'm Duke \n"
+ + "What can I do for you?");
+ }
+
+ String readInput() {
+ return this.sc.nextLine();
+ }
+
+ void showLoadingError() {
+ System.out.println("Loading Error!");
+ }
+ }
+
+ public static class Parser {
+ String nextLine;
+ TaskList inputs;
+
+<<<<<<< HEAD
+ Parser(String nextLine, TaskList inputs) {
+ this.nextLine = nextLine;
+ this.inputs = inputs;
+ }
+
+ void parse() throws DukeException {
+ try {
+ if (nextLine.startsWith("done")) {
+ inputs.taskDone(nextLine);
+ } else if (nextLine.startsWith("remove")) {
+ inputs.taskRemove(nextLine);
+ } else if (nextLine.startsWith("todo")) {
+ inputs.taskTodo(nextLine);
+ } else if (nextLine.startsWith("deadline")) {
+ inputs.taskDeadline(nextLine);
+ } else if (nextLine.startsWith("event")) {
+ inputs.taskEvent(nextLine);
+ } else if (nextLine.equals("list")) {
+ if (inputs.inputs.size() == 0) {
+ System.out.println("No tasks in list");
+ } else {
+ System.out.println("Here are the tasks in your list:");
+ int len = inputs.inputs.size();
+ for (int i = 1; i <= len; i++) {
+ Input inputType = inputs.inputs.get(i - 1);
+ if (inputType.isDone) {
+ System.out.println(i + ". " + inputType.id + "[/] " + inputType.content +
+ inputType.printedTime);
+ } else {
+ System.out.println(i + ". " + inputType.id + "[x] " + inputType.content +
+ inputType.printedTime);
+=======
+ void parse() throws DukeException {
+ try {
+ if (nextLine.startsWith("done")) {
+ inputs.taskDone(nextLine);
+ } else if (nextLine.startsWith("remove")) {
+ inputs.taskRemove(nextLine);
+ } else if (nextLine.startsWith("todo")) {
+ inputs.taskTodo(nextLine);
+ } else if (nextLine.startsWith("deadline")) {
+ inputs.taskDeadline(nextLine);
+ } else if (nextLine.startsWith("event")) {
+ inputs.taskEvent(nextLine);
+ } else if (nextLine.startsWith("find")) {
+ inputs.taskFind(nextLine);
+ } else if (nextLine.equals("list")) {
+ if (inputs.inputs.size() == 0) {
+ System.out.println("No tasks in list");
+ } else {
+ System.out.println("Here are the tasks in your list:");
+ int len = inputs.inputs.size();
+ for (int i = 1; i <= len; i++) {
+ Input inputType = inputs.inputs.get(i - 1);
+ if (inputType.done) {
+ System.out.println(i + ". " + inputType.id + "[/] " + inputType.content +
+ inputType.printTime);
+ } else {
+ System.out.println(i + ". " + inputType.id + "[x] " + inputType.content +
+ inputType.printTime);
+ }
+>>>>>>> branch-Level-9
+ }
+ }
+ }
+ } else {
+ throw new DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
+ }
+ } catch (DukeException e) {
+ System.out.println(e.msg);
+ }
+ }
+ }
+}
+
+
+
\ No newline at end of file
diff --git a/src/main/java/Launcher.java b/src/main/java/Launcher.java
new file mode 100644
index 0000000000..9f8656fb02
--- /dev/null
+++ b/src/main/java/Launcher.java
@@ -0,0 +1,18 @@
+import javafx.application.Application;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.control.Label;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.HBox;
+import javafx.stage.Stage;
+
+public class Launcher {
+ public static void main(String args[]) {
+ Application.launch(Main.class, args);
+ }
+}
+
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
new file mode 100644
index 0000000000..318bd74bbb
--- /dev/null
+++ b/src/main/java/Main.java
@@ -0,0 +1,29 @@
+import java.io.IOException;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.AnchorPane;
+import javafx.stage.Stage;
+
+/**
+ * A GUI for 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..d376e1be4f
--- /dev/null
+++ b/src/main/java/MainWindow.java
@@ -0,0 +1,57 @@
+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.Region;
+import javafx.scene.layout.VBox;
+
+import java.io.UnsupportedEncodingException;
+
+public class MainWindow extends AnchorPane {
+ /**
+ * Controller for MainWindow. Provides the layout for the other controls.
+ */
+ @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"));
+
+ @FXML
+ public void initialize() {
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ }
+
+ public void setDuke(Duke d) {
+ duke = d;
+ dialogContainer.getChildren().addAll(
+ DialogBox.getDukeDialog("Welcome to Duke! How may I help you?", dukeImage)
+ );
+ }
+
+ /**
+ * 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() throws UnsupportedEncodingException, Duke.DukeException {
+ 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/resources/images/DaDuke.png b/src/main/resources/images/DaDuke.png
new file mode 100644
index 0000000000..f342434252
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..13ea0b647f
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..409f52b5c7
--- /dev/null
+++ b/src/main/resources/view/DialogBox.fxml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
new file mode 100644
index 0000000000..4f5521273b
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/DukeTest.java b/src/test/java/DukeTest.java
new file mode 100644
index 0000000000..8a2286557a
--- /dev/null
+++ b/src/test/java/DukeTest.java
@@ -0,0 +1,45 @@
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+
+public class DukeTest {
+ @Test
+ public void dummyTest() {
+ assertEquals(2,2);
+ }
+
+ @Test
+ public void todoExceptionTest() throws Duke.DukeException {
+ try {
+ Duke.TaskList Tasks = new Duke.TaskList(new ArrayList<>());
+ Tasks.taskTodo("todo");
+ } catch (Duke.DukeException e) {
+ assertEquals("OOPS!!! The description of a todo cannot be empty.", e.msg);
+ }
+ }
+
+ @Test
+ public void deadlineExceptionTest() throws Duke.DukeException {
+ try {
+ Duke.TaskList Tasks = new Duke.TaskList(new ArrayList<>());
+ Tasks.taskDeadline("deadline");
+ } catch (Duke.DukeException e) {
+ assertEquals("OOPS!!! The description of a deadline cannot be empty.", e.msg);
+ }
+ }
+
+ @Test
+ public void parserExceptionTest() throws Duke.DukeException {
+ try {
+ Duke.Parser testParser = new Duke.Parser("blah", new Duke.TaskList());
+ testParser.parse();
+ } catch (Duke.DukeException e) {
+ assertEquals("OOPS!!! I'm sorry, but I don't know what that means :-(", e.msg);
+ }
+ }
+
+
+
+
+}
+
diff --git a/text-ui-test/Downloading b/text-ui-test/Downloading
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT
index 657e74f6e7..a1e19cfb82 100644
--- a/text-ui-test/EXPECTED.TXT
+++ b/text-ui-test/EXPECTED.TXT
@@ -5,3 +5,27 @@ Hello from
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
+Hello! I'm Duke
+What can I do for you?
+Got it. I've added this task:
+ [T][x] borrow book
+ Now you have 1 tasks in the list
+Got it. I've added this task:
+ [D][x] return book (by: Sunday)
+ Now you have 2 tasks in the list
+Got it. I've added this task:
+ [E][x] project meeting (at: Mon 2-4pm)
+ Now you have 3 tasks in the list
+Here are the tasks in your list:
+1. [T][x] borrow book
+2. [D][x] return book (by: Sunday)
+3. [E][x] project meeting (at: Mon 2-4pm)
+Nice! I've marked this task as done:
+[/] return book (by: Sunday)
+Nice! I've marked this task as done:
+[/] borrow book
+Here are the tasks in your list:
+1. [T][/] borrow book
+2. [D][/] return book (by: Sunday)
+3. [E][x] project meeting (at: Mon 2-4pm)
+Bye. Hope to see you again soon!
diff --git a/text-ui-test/Pouring b/text-ui-test/Pouring
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt
index e69de29bb2..54e475d8e6 100644
--- a/text-ui-test/input.txt
+++ b/text-ui-test/input.txt
@@ -0,0 +1,8 @@
+todo borrow book
+deadline return book /by Sunday
+event project meeting /at Mon 2-4pm
+list
+done 2
+done 1
+list
+bye
\ No newline at end of file
diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh
old mode 100644
new mode 100755
index e169618a34..dd732a38bd
--- a/text-ui-test/runtest.sh
+++ b/text-ui-test/runtest.sh
@@ -13,7 +13,7 @@ then
fi
# compile the code into the bin folder, terminates if error occurred
-if ! javac -cp ../src -Xlint:none -d ../bin ../src/main/java/Duke.java
+if ! javac -cp ../src -Xlint:none -d ../bin ../src/main/java/*.java
then
echo "********** BUILD FAILURE **********"
exit 1
@@ -27,7 +27,7 @@ cp EXPECTED.TXT EXPECTED-UNIX.TXT
dos2unix ACTUAL.TXT EXPECTED-UNIX.TXT
# compare the output to the expected output
-diff ACTUAL.TXT EXPECTED-UNIX.TXT
+diff ACTUAL.TXT EXPECTED-UNIX.TXT | cat -t
if [ $? -eq 0 ]
then
echo "Test result: PASSED"
@@ -35,4 +35,4 @@ then
else
echo "Test result: FAILED"
exit 1
-fi
\ No newline at end of file
+fi