diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..9794b4a3b0 --- /dev/null +++ b/build.gradle @@ -0,0 +1,75 @@ +plugins { + id 'java' + id 'application' + id 'checkstyle' + id 'com.github.johnrengelman.shadow' version '5.1.0' + id 'org.openjfx.javafxplugin' version '0.0.8' +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0' + testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0' +} + +test { + useJUnitPlatform() + + testLogging { + events "passed", "skipped", "failed" + + showExceptions true + exceptionFormat "full" + showCauses true + showStackTraces true + showStandardStreams = false + } +} + +application { + mainClassName = "Launcher" +} + +javafx { + version = "11" + modules = [ 'javafx.controls', 'javafx.fxml'] +} + +shadowJar { + archiveBaseName = "duke" + archiveClassifier = null +} + +checkstyle { + toolVersion = '8.29' + configFile = file("${rootDir}/config/checkstyle/checkstyle.xml") +} + +repositories { + mavenCentral() +} + +dependencies { + String javaFxVersion = '11' + + implementation group: 'org.openjfx', name: 'javafx-media', version: javaFxVersion, classifier: 'win' + 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' +} + +run { + standardInput = System.in +} \ No newline at end of file diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..502fbd3a58 --- /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..dcaa1af3c3 --- /dev/null +++ b/config/checkstyle/suppressions.xml @@ -0,0 +1,10 @@ + + + + + + + + \ No newline at end of file diff --git a/data/archive.txt b/data/archive.txt new file mode 100644 index 0000000000..3cf3e62dbd --- /dev/null +++ b/data/archive.txt @@ -0,0 +1,7 @@ +T | 0 | 1 +T | 0 | 2 +T | 0 | 2 +T | 0 | 2 +T | 0 | 2 +T | 0 | 2 +T | 0 | 2 diff --git a/data/duke.txt b/data/duke.txt new file mode 100644 index 0000000000..b4528049a0 --- /dev/null +++ b/data/duke.txt @@ -0,0 +1 @@ +T | 1 | smash diff --git a/docs/README.md b/docs/README.md index fd44069597..08a67279af 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,19 +2,233 @@ ## Features -### Feature 1 -Description of feature. ++ Greet Doge Duke: `hi` ++ Add a **Todo** command: `todo` ++ Add an **Deadline** command: `deadline` ++ Add an **Event** command: `event` ++ List all commands : `list` ++ Complete a command: `done` ++ Delete a command : `delete` ++ Locate a command : `find` ++ Archive all commands: `archive` ++ Retrieve archived commands: `retrieve` ++ Exit Doge Duke : `bye` ## Usage -### `Keyword` - Describe action +### `hello` - Greet Doge Duke -Describe action and its outcome. +Starts the Doge Duke Programme. -Example of usage: +Format: `hello` -`keyword (optional arguments)` +Example of usage: +``` +hello +``` Expected outcome: -`outcome` +``` +Woof! I'm Doge Duke +What do you want me to do? +Type your request in below! +``` + +### `todo` - Add a Todo command +Adds a Todo Command to the current working Commands List. + +Format: `todo {COMMAND_DESCRIPTION}` ++ `{COMMAND_DESCRIPTION}` is added to the Command List. + + +Example of usage: + +``` +todo rollover +``` + +Expected outcome: + +``` +Mlem I've added a new command for you to do: +[T] [ ] rollover +Now I can do a total of 1 commands! +``` + +### `deadline` - Add a Deadline command +Adds a Deadline Command to the current working Commands List. + +Format: `deadline {COMMAND_DESCRIPTION} /by {DUE_DATE}` ++ `{COMMAND_DESCRIPTION}` is added to the Command List. ++ `{DUE_DATE}` isis added as a Due Date in YYYY-MM-DD format. + +Example of usage: + +``` +deadline finish doggo treats /by 2021-03-11 +``` + +Expected outcome: + +``` +Woofers! I've added a new command with a Ded-line: +[D] [ ] finish doggo treats | by: 11 Mar 2021 +Now I can do a total of 3 commands! +``` + +### `event` - Add a Event command +Adds a Event Command to the current working Commands List. + +Format: `event {COMMAND_DESCRIPTION} /by {EVENT_DATE}` ++ `{COMMAND_DESCRIPTION}` is added to the Command List. ++ `{EVENT_DATE}` is added as a Event Date in YYYY-MM-DD format. + +Example of usage: + +``` +event dog festival /at 2021-02-10 +``` + +Expected outcome: + +``` +Much wow! I've added a new command with an Event: +[E] [ ] dog festival | at: 10 Feb 2021 +Now I can do a total of 2 commands! +``` + +### `list` - List all commands +Lists all Commands in the current working Command List in +an indexed format. + +Format: `list` + +Example of usage: + +``` +list +``` + +Expected outcome: + +``` +1. [T] [ ] rollover +2. [D] [ ] finish doggo treats | by: 11 Mar 2021 +``` + +### `done` - Complete a command +Mark a Command for which the index/id is identified by the user +as Done from the current working Command List. + +Format: `done {COMMAND_ID}` ++ Marks the Command numbered {COMMAND_ID} in the Command List as Done. + +Example of usage: + +``` +done 2 +``` + +Expected outcome: + +``` +1. [T] [ ] rollover +2. [D] [X] finish doggo treats | by: 11 Mar 2021 +``` + +### `delete` - Delete a command +Deletes the Command for which the index/id is identified by the user +from the current working Command List. + +Format: `delete {COMMAND_ID}` ++ Delete the Command numbered {COMMAND_ID} in the Command List. + +Example of usage: + +``` +delete 2 +``` + +Expected outcome: + +``` +1. [T] [ ] rollover +``` + +### `find` - Locate a command +Deletes the Command for which the index/id is identified by the user +from the current working Command List. + +Format: `find {KEYWORD}` ++ Searches for `KEYWORD` in all the Command Descriptions of Commands in the current working +Command list. + +Example of usage: + +``` +find roll +``` + +Expected outcome: + +``` +1. [T] [ ] rollover +2. [T] [ ] roll back +``` + +### `archive` - Archive all commands +Archive all Commands in the current working Command List to +a text file located in the data directory. User will start on a clean +slate, Command List will be empty. + +Format: `archive` + +Example of usage: + +``` +archive +``` + +Expected outcome: + +``` +Archived all commands in text file in your data folder! +``` + +### `retrieve` - Retrieved Archive commands +Retrieves all Commands previously archived and appends to +the back of current working Command List. + +Format: `retrieve` + +Example of usage: + +``` +retrieve +``` + +Expected outcome: + +``` +Your archived commands have been added back to your +current commands! +``` + +### `bye` - Exit Doge Duke +Terminates the Doge Duke Programme. + +Format: `bye` + +Example of usage: + +``` +bye +``` + +Expected outcome: + +``` +Bye! Hope I was a good dog, see you again soon! +``` + diff --git a/docs/Ui.png b/docs/Ui.png new file mode 100644 index 0000000000..8b46cbed34 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..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/DialogBox.java b/src/main/java/DialogBox.java new file mode 100644 index 0000000000..92202b3fec --- /dev/null +++ b/src/main/java/DialogBox.java @@ -0,0 +1,74 @@ +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; + +public class DialogBox extends HBox { + @FXML + private Label dialog; + @FXML + private ImageView displayPicture; + + private DialogBox(Image img, Label l) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml")); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + fxmlLoader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + dialog.setText(l.getText()); + dialog.setWrapText(true); + displayPicture.setImage(img); + setHeight(l); + } + + /** + * 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); + } + + /** + * ensures text bubble fits the length of long inputs + * + * @param l Label generated from duke response + */ + //@@lll-jy kwmiw-reused + //Reused from https://github.com/lll-jy/ip/blob/master/src/main/java/DialogBox.java + // with minor modifications to add on text bubble length + private void setHeight(Label l) { + int count = l.getText().endsWith("\n") ? 1 : 0; + String[] ss = l.getText().split("\n"); + count += ss.length + 1; + for (String s : ss) { + count += s.length() / 32; + } + this.setMinHeight(count * 15 + 50); + } + + public static DialogBox getUserDialog(Label l, Image img) { + return new DialogBox(img, l); + } + + public static DialogBox getDukeDialog(Label l, Image img) { + var db = new DialogBox(img, l); + db.flip(); + return db; + } +} 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/Launcher.java b/src/main/java/Launcher.java new file mode 100644 index 0000000000..43d64c26fb --- /dev/null +++ b/src/main/java/Launcher.java @@ -0,0 +1,10 @@ +import javafx.application.Application; + +/** + * A launcher class to workaround classpath issues. + */ +public class Launcher { + public static void main(String[] args) { + Application.launch(Main.class, args); + } +} diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000000..5d824f0642 --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,31 @@ +import java.io.IOException; + +import duke.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(); + + @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); + stage.setTitle("Doge Duke"); + fxmlLoader.getController().setDuke(duke); + stage.show(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/MainWindow.java b/src/main/java/MainWindow.java new file mode 100644 index 0000000000..a3262a215c --- /dev/null +++ b/src/main/java/MainWindow.java @@ -0,0 +1,54 @@ +import duke.Duke; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; + +/** + * Controller for MainWindow. Provides the layout for the other controls. + */ +public class MainWindow extends AnchorPane { + @FXML + private ScrollPane scrollPane; + @FXML + private VBox dialogContainer; + @FXML + private TextField userInput; + @FXML + private Button sendButton; + + private Duke duke; + + private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.jpg")); + private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDukeDoge.jpg")); + + @FXML + public void initialize() { + scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); + } + + public void setDuke(Duke d) { + duke = d; + } + + /** + * Creates two dialog boxes, one echoing user input + * and the other containingDuke's reply and then + * appends them to the dialog container. + * Clears the user input after processing. + */ + @FXML + private void handleUserInput() { + String input = userInput.getText(); + Label response = duke.getResponse(input); + dialogContainer.getChildren().addAll( + DialogBox.getUserDialog(new Label(input), userImage), + DialogBox.getDukeDialog(response, dukeImage) + ); + userInput.clear(); + } +} diff --git a/src/main/java/duke/Command.java b/src/main/java/duke/Command.java new file mode 100644 index 0000000000..80907d2ded --- /dev/null +++ b/src/main/java/duke/Command.java @@ -0,0 +1,61 @@ +package duke; + +/** Represents Command that Doge can do, with a description + * attached and primary behaviour to mark command as done + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ +public class Command { + private String commandDescription; + private boolean isDone; + + /** + * Constructor for Command + * + * @param commandDescription every command has a description attached + */ + public Command(String commandDescription) { + this.commandDescription = commandDescription; + this.isDone = false; + } + + /** + * Mark command as Done + * + * @return Command that is marked as Done + */ + public Command markDone() { + this.isDone = true; + return this; + } + + public String getDescription() { + return this.commandDescription; + } + + /** + * Check if command is marked as done, Command is + * done when indicated with 1 and vice versa 0 + * + * @return String to indicate Done attribute + */ + public String getDone() { + if (isDone) { + return " 1 "; + } else { + return " 0 "; + } + } + + @Override + public String toString() { + if (this.isDone) { + return "[X] " + this.commandDescription; + } else { + return "[ ] " + this.commandDescription; + } + } + +} diff --git a/src/main/java/duke/CommandList.java b/src/main/java/duke/CommandList.java new file mode 100644 index 0000000000..3cbfb70912 --- /dev/null +++ b/src/main/java/duke/CommandList.java @@ -0,0 +1,179 @@ +package duke; + +import java.nio.file.Path; +import java.util.ArrayList; + +/** Represents Command list containing commands and carries + * methods to print, add, delete and indicate command as done. + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ +public class CommandList { + private ArrayList commands = new ArrayList(); + private ArrayList archivedCommands = new ArrayList(); + private Storage storage; + private Storage archiveStorage; + + /** + * Constructor for command list + * + * @param storage to reference storage instance to save most updated command list + */ + public CommandList(Storage storage) { + this.storage = storage; + } + + /** + * Iterates through non-empty commands list + * and prints each command in ascending order + * + * @return Numbered Printed List + */ + String printList() { + String result = ""; + if (commands.size() == 0) { + result = "Your list of commands are currently empty!\n"; + } else { + for (int i = 0; i < commands.size(); i++) { + Command value = commands.get(i); + result += ((i + 1) + ". " + value + "\n"); + } + } + return result; + } + + /** + * Adds and saves a single command to the command list, + * printing out appropriate Ui based on command + * type + * + * @param command command of children classes ToDo, Deadline, Event + * @param commandType identifier to sort command classes + * @return Added notification to user + */ + String addCommand(Command command, String commandType) { + commands.add(command); + int size = commands.size(); + storage.save(storage.getFilePath(), storage.getPath(), commands); + + if (commandType.equals("T")) { + return Ui.printToDo(command, size); + } else if (commandType.equals("D")) { + return Ui.printDeadline(command, size); + } else { + return Ui.printEvent(command, size); + } + } + + /** + * Marks a single command as done based on its index + * with markDone(), saves the updated command list and + * printing out appropriate Ui to notify user + * + * @param id index of command to be marked done in commands list + * @return Done notification to user + * @see duke.Command#markDone() markDone + */ + String doneCommand(int id) { + Command command = commands.get(id); + command.markDone(); + storage.save(storage.getFilePath(), storage.getPath(), commands); + return Ui.printDone(command); + } + + /** + * Deletes a single command off command list based + * on its index, saving the new command list and + * printing out appropriate Ui to notify user + * + * @param id index of command to be marked done in commands list + * @return Delete notification to user + * @see duke.Command#markDone() markDone + */ + String deleteCommand(int id) { + Command command = commands.get(id); + commands.remove(id); + int size = commands.size(); + storage.save(storage.getFilePath(), storage.getPath(), commands); + return Ui.printDelete(command, size); + } + + /** + * Searches all commands in commandList that match + * given keyword given by owner + * + * @param keyWord to match during search for user + * @return results of search of keyWord to user + */ + public String findCommand(String keyWord) { + ArrayList targetList = new ArrayList(); + String result = ""; + + for (int i = 0; i < commands.size(); i++) { + Command value = commands.get(i); + String description = value.getDescription(); + if (description.contains(keyWord)) { + targetList.add(value); + } + } + + if (commands.isEmpty()) { + result = "Your list of commands are currently empty!\n"; + } else { + if (targetList.isEmpty()) { + result = Ui.printFind(targetList, false); + } else { + result = Ui.printFind(targetList, true); + } + } + return result; + } + + /** + * Archives all Commands in the current Command + * List to a text file named archive.txt in the data file + * (same format as storage.save) + * + * @return Successful Archive notification to user + * @see duke.Storage#save(String, Path, ArrayList) save + */ + public String archiveCommand() { + archiveStorage = new Storage(storage.getArchiveFilePath(), + storage.getArchivePath()); + + archivedCommands = commands; + + archiveStorage.save(storage.getArchiveFilePath(), + storage.getArchivePath(), + archivedCommands); + + commands = new ArrayList(); + return Ui.printArchiveCompleted(); + } + + /** + * Retrieves the previously archived commands and + * appends them to the current working Command List + * + * @return Successful Archive notification to user + * @see duke.Storage#save(String, Path, ArrayList) save + */ + public String retrieveCommand() { + int size = commands.size(); + + if (size == 0) { + commands = archivedCommands; + } else { + commands.addAll(archivedCommands); + } + + storage.save(storage.getFilePath(), + storage.getPath(), + commands); + + return Ui.printRetrievalCompleted(); + } +} + diff --git a/src/main/java/duke/Deadline.java b/src/main/java/duke/Deadline.java new file mode 100644 index 0000000000..c0f4431705 --- /dev/null +++ b/src/main/java/duke/Deadline.java @@ -0,0 +1,42 @@ +package duke; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +/** Represents Deadline inherited from Command, + * attached with command description and due date + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ +public class Deadline extends duke.Command { + + private final boolean isDone; + private String formattedDate; + private LocalDate dueDate; + + /** + * Constructor for Command child class Deadline + * + * @param commandDescription every command has a description attached + * @param dueDate date when command is due + */ + public Deadline(String commandDescription, LocalDate dueDate) { + super(commandDescription); + this.isDone = false; + this.dueDate = dueDate; + + DateTimeFormatter format = DateTimeFormatter.ofPattern("dd MMM yyyy"); + this.formattedDate = this.dueDate.format(format); + } + + public LocalDate getTime() { + return this.dueDate; + } + + @Override + public String toString() { + return "[D] " + super.toString() + " | by: " + formattedDate; + } +} diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java new file mode 100644 index 0000000000..181bb467f7 --- /dev/null +++ b/src/main/java/duke/Duke.java @@ -0,0 +1,50 @@ +package duke; + +/* + Doge Duke implements a virtual pet application that + returns different commands passed by owner (user). + + @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-01-31 + */ + + +import javafx.scene.control.Label; + +public class Duke { + + final CommandList commandList; + private Storage storage; + private Ui ui; + private Parser parser; + + /** + * Constructor of Duke class + */ + public Duke() { + this.storage = new Storage(); + this.commandList = new CommandList(storage); + this.ui = new Ui(); + this.parser = new Parser(commandList); + } + + /** + * Generate a response to user input for GUI + * + * @param input raw user input from GUI + */ + public Label getResponse(String input) { + String result = ""; + Label response = null; + try { + result = parser.parseAll(input); + + } catch (Exception e) { + result = parser.errorHandling(input); + } + response = new Label(result); + return response; + } + +} diff --git a/src/main/java/duke/DukeException.java b/src/main/java/duke/DukeException.java new file mode 100644 index 0000000000..5afa368b6f --- /dev/null +++ b/src/main/java/duke/DukeException.java @@ -0,0 +1,9 @@ +package duke; + +public class DukeException extends Exception { + + public DukeException(String errorMsg) { + super(errorMsg); + } + +} diff --git a/src/main/java/duke/DukeTest.java b/src/main/java/duke/DukeTest.java new file mode 100644 index 0000000000..7e6f6756cb --- /dev/null +++ b/src/main/java/duke/DukeTest.java @@ -0,0 +1,4 @@ +package duke; + +public class DukeTest { +} diff --git a/src/main/java/duke/Event.java b/src/main/java/duke/Event.java new file mode 100644 index 0000000000..2e7d515ae2 --- /dev/null +++ b/src/main/java/duke/Event.java @@ -0,0 +1,41 @@ +package duke; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +/** Represents Event inherited from Command, + * attached with command description and due date + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ +public class Event extends duke.Command { + private final boolean isDone; + private LocalDate eventDate; + private String formattedDate; + + /** + * Constructor for Command child class Event + * + * @param commandDescription every command has a description attached + * @param eventDate date when event is held + */ + public Event(String commandDescription, LocalDate eventDate) { + super(commandDescription); + this.isDone = false; + this.eventDate = eventDate; + + DateTimeFormatter format = DateTimeFormatter.ofPattern("dd MMM yyyy"); + this.formattedDate = this.eventDate.format(format); + } + + public LocalDate getTime() { + return this.eventDate; + } + + @Override + public String toString() { + return "[E] " + super.toString() + " | at: " + formattedDate; + } +} diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java new file mode 100644 index 0000000000..da913d2cef --- /dev/null +++ b/src/main/java/duke/Parser.java @@ -0,0 +1,223 @@ +package duke; + +import java.time.LocalDate; +import java.time.format.DateTimeParseException; + +/** Processes user input and possible input-based errors + * and sorts to relevant commandList methods or displays + * correct error messages to prompt user for correct inputs. + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ +public class Parser { + private CommandList commandList; + private final String regexSpace = " "; + private final String regexToDo = " "; + private final String regexDeadline = " /by "; + private final String regexEvent = " /at "; + private final String terminate = "bye"; + + public Parser(CommandList commandList) { + this.commandList = commandList; + } + + /** + * Handles and displays specified error + * messages as per different cases of + * incorrect user input + * + * @param errorInput Raw user input + * @return Error Message to prompt correct input from user + */ + static String errorHandling(String errorInput) { + String[] inputArr = new String[100]; + String result = ""; + + if (errorInput.contains(" ")) { + inputArr = errorInput.split(" "); + } else { + inputArr[0] = errorInput; + } + + if ((errorInput.contains("todo") + || errorInput.contains("deadline") + || errorInput.contains("event")) + && inputArr[1] == null) { + + result = ("Eh? Your command description cannot be empty." + + "Try again!"); + + } else if (errorInput.contains("list") + || errorInput.contains("bye")) { + //Do nothing + + } else if ((errorInput.contains("done") + || errorInput.contains("delete")) + && inputArr[1] == null) { + + result = ("What are you referring to?" + + " Remember to key in the correct command id!"); + + } else if (inputArr[1] != null) { + //Do nothing + + // Invalid description: unknown + } else { + result = ("Whoops :( I'm sorry, I'm not sure what that means. " + + "Did you forget to add a command type?"); + } + + return result; + } + + /** + * Sorts user input accordingly and splits input by + * command type to relay formatted input to addCommand + * + * @param input Raw user input to add commands + * @return Added notification to user + * @exception DateTimeParseException if the LocalDate user input is in wrong format + * @see duke.CommandList#addCommand(Command, String) addCommand + */ + String parseAdd(String input) { + Command command; + String result = ""; + try { + if (input.contains("todo")) { + String[] description = input.split(regexToDo); + command = new ToDo(input.substring(5)); + result = commandList.addCommand(command, "T"); + + } else if (input.contains("deadline")) { + String[] inputTime = input.split(regexDeadline); + LocalDate parseDate = LocalDate.parse(inputTime[1].trim()); + command = new Deadline(inputTime[0].substring(9), parseDate); + result = commandList.addCommand(command, "D"); + + } else if (input.contains("event")) { + String[] inputTime = input.split(regexDeadline); + LocalDate parseDate = LocalDate.parse(inputTime[1].trim()); + command = new Event(inputTime[0].substring(6), parseDate); + result = commandList.addCommand(command, "E"); + + } else { + result = "An error occurred, did you add the correct command?"; + } + } catch (DateTimeParseException e) { + result = ("This date doesnt exist! " + + "The right format should be in yyyy-mm-dd."); + return result; + } + return result; + } + + String parseList() { + return commandList.printList(); + } + + /** + * Splits input to get id of desired done command + * to relay formatted input to doneCommand + * + * @param input Raw user input to mark command + * @return Done notification to user + * @see duke.CommandList#doneCommand(int) doneCommand + */ + String parseDone(String input) { + String[] doneInput = input.split(regexSpace); + int id = Integer.parseInt(doneInput[1]) - 1; + return commandList.doneCommand(id); + } + + /** + * Splits input to get id of desired deleted command + * to relay formatted input to deleteCommand + * + * @param input Raw user input to delete command + * @return Delete notification to user + * @see duke.CommandList#deleteCommand(int) deleteCommand + */ + String parseDelete(String input) { + String[] deleteInput = input.split(regexSpace); + int id = Integer.parseInt(deleteInput[1]) - 1; + return commandList.deleteCommand(id); + } + + /** + * Splits input to get keyWord from user + * to relay formatted input to findCommand + * + * @param input Raw user input to mark command + * @return Found or Missing keyWord notification to user + * @see duke.CommandList#findCommand(String) findCommand + */ + String parseFind(String input) { + String[] findInput = input.split(regexSpace); + return commandList.findCommand(findInput[1]); + } + + String parseArchive(String input) { + String result = ""; + if (input.contains("retrieve")) { + result = commandList.retrieveCommand(); + } else { + result = commandList.archiveCommand(); + } + return result; + } + + /** + * Introduces scanner class to read in input + * and sorts input into appropriate parsing commands + * + * @param input Raw user input from GUI + * @return Relevant response to user + */ + public String parseAll(String input) { + assert input.length() > 0 : "Command cannot be empty"; + String result = ""; + try { + result = errorHandling(input); + + if (input.equals(terminate)) { + result = Ui.printGoodbye(); + new SoundBark().playAudio(); + + } else if (input.equals("list")) { + result = parseList(); + + } else if (input.contains("hello") + || input.equals("hello")) { + result = Ui.printGreet(); + new SoundBark().playAudio(); + + } else if (input.contains("done")) { + result = parseDone(input); + + } else if (input.contains("delete")) { + result = parseDelete(input); + + } else if (input.contains("find")) { + result = parseFind(input); + + } else if (input.contains("todo") + || input.contains("deadline") + || input.contains("event")) { + result = parseAdd(input); + + } else if (input.contains("archive") + || input.equals("archive")) { + result = parseArchive(input); + + } else { + result = Ui.printGeneralError(); + } + } catch (Exception e) { + System.out.println(e); + } + return result; + } + +} diff --git a/src/main/java/duke/SoundBark.java b/src/main/java/duke/SoundBark.java new file mode 100644 index 0000000000..ec8210a4fc --- /dev/null +++ b/src/main/java/duke/SoundBark.java @@ -0,0 +1,41 @@ +package duke; + +import java.io.File; +import java.io.IOException; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + +/** Barking Noise enabled during start + * and duke doge termination to greet and bid + * farewell to the user + * + * @author Chia Jia-Xi, Kymie + * @version 0.2 + * @since 2021-02-24 + */ +public class SoundBark { + + private String audioPath = "./src/main/java/sfx/464400__michael-grinnell__dog-bark.wav"; + + /** + * Enables JavaFX to play bark audio clip + * at greeting and farewell + * + * @throws IOException + * @throws LineUnavailableException if Audio Byte format is off (16-bit supported by Desktop) + * @throws UnsupportedAudioFileException if Audio file is in incorrect format + */ + // Solution below adapted from https://www3.ntu.edu.sg/home/ehchua/programming/java/J8c_PlayingSound.html + void playAudio() throws IOException, LineUnavailableException, UnsupportedAudioFileException { + File soundFile = new File(audioPath); + AudioInputStream audioIn = AudioSystem.getAudioInputStream(soundFile); + + Clip clip = AudioSystem.getClip(); + clip.open(audioIn); + + clip.start(); + } +} diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java new file mode 100644 index 0000000000..d11f5fec96 --- /dev/null +++ b/src/main/java/duke/Storage.java @@ -0,0 +1,132 @@ +package duke; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; + +/** Storage class saves most updated command list + * to desired directories and files + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ +public class Storage { + + private String filePath = "./data/duke.txt"; + private Path path = Paths.get("./data/duke.txt"); + + private String archiveFilePath = "./data/archive.txt"; + private Path archivePath = Paths.get("./data/archive.txt"); + + + public Storage() { + new Storage(filePath, path); + } + + /** + * Constructor for storage + * + * @param filePath of desired directory and file name + * @param path path of desired directory and file name + */ + public Storage(String filePath, Path path) { + this.filePath = filePath; + this.path = path; + } + + public String getFilePath() { + return filePath; + } + + public Path getPath() { + return path; + } + + public String getArchiveFilePath() { + return archiveFilePath; + } + + public Path getArchivePath() { + return archivePath; + } + + /** + * Checks if existing data directory and duke.txt file + * has been created, else create them with given file + * paths from the root folder + * + * @param filePath desired path to save duke.txt + * @param path desired path to save duke.txt in Path + */ + public void checkPath(String filePath, Path path) { + try { + File file = new File(filePath); + + boolean isDir = Files.isDirectory(path); + + if (isDir) { + //directory exists, proceed. + } else { + Files.createDirectories(Path.of(file.getParent())); + } + + } catch (IOException e) { + System.out.println("An error occurred."); + e.printStackTrace(); + } + } + + /** + * Method saves the current Command list + * into a text file + * + * @param filePath Filepath of text file to save to + * @param path path of text file to save to + * @param xs most updated command list to be saved + */ + void save(String filePath, Path path, ArrayList xs) { + try { + checkPath(filePath, path); + FileWriter fw = new FileWriter(filePath); + + for (Command c : xs) { + if (c instanceof ToDo) { + fw.write("T |" + + c.getDone() + + "| " + + c.getDescription() + + "\n"); + + } else if (c instanceof Deadline) { + fw.write("D |" + + c.getDone() + + "| " + + c.getDescription() + + " | " + + ((Deadline) c).getTime() + + "\n"); + + } else if (c instanceof Event) { + fw.write("E |" + + c.getDone() + + "| " + + c.getDescription() + + " | " + + ((Event) c).getTime() + + "\n"); + } else { + } + } + fw.close(); + + } catch (IOException e) { + System.out.println("An error occurred."); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/duke/ToDo.java b/src/main/java/duke/ToDo.java new file mode 100644 index 0000000000..9ea234f12c --- /dev/null +++ b/src/main/java/duke/ToDo.java @@ -0,0 +1,29 @@ +package duke; + +/** Represents ToDo inherited from Command, + * attached with command description + * + * @author Chia Jia-Xi, Kymie + * @version 0.1 + * @since 2021-02-22 + */ + +public class ToDo extends Command { + + private final boolean isDone; + + /** + * Constructor for Command child class ToDo + * + * @param commandDescription every command has a description attached + */ + public ToDo(String commandDescription) { + super(commandDescription); + this.isDone = false; + } + + @Override + public String toString() { + return "[T] " + super.toString(); + } +} diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java new file mode 100644 index 0000000000..c924cc2e8f --- /dev/null +++ b/src/main/java/duke/Ui.java @@ -0,0 +1,98 @@ +package duke; + +import java.util.ArrayList; + +public class Ui { + + private static String greet = "Woof! I'm Doge Duke\n" + + "What do you want me to do?\n" + + "Type your request in below!"; + + private static String goodbye = "Bye! Hope I was a good dog, " + + "see you again soon!"; + + static String printGreet() { + return greet; + } + + static String printGoodbye() { + return goodbye; + } + + static String printGeneralError() { + return ("Sorry, I can't recognise this." + + " Maybe try another command?"); + } + + static String indexList(ArrayList xs) { + String result = ""; + for (int i = 0; i < xs.size(); i++) { + Command value = xs.get(i); + result += (i + 1) + ". " + value + "\n"; + } + return result; + } + + static String printToDo(Command command, int size) { + return "Mlem I've added a new command for you to do:\n" + + command + + "\n" + + "Now I can do a total of " + + size + + " commands!"; + } + + static String printDeadline(Command command, int size) { + return "Woofers! I've added a new command with a Ded-line:\n" + + command + + "\n" + + "Now I can do a total of " + + size + + " commands!"; + } + + static String printEvent(Command command, int size) { + return "Much wow! I've added a new command with an Event:\n" + + command + + "\n" + + "Now I can do a total of " + + size + + " commands!"; + } + + static String printDone(Command command) { + return "Very Woof! " + + "I have completed this commands:\n" + + command + + "\n"; + } + + static String printDelete(Command command, int size) { + return "Noted! " + + "This task has been removed:\n" + + command + + "\n" + + "Now you have " + + size + + " commands remaining."; + } + + static String printFind(ArrayList targetList, boolean isFound) { + if (isFound) { + return "We found some matching commands:\n" + + indexList(targetList); + } else { + return "Omo :( " + + "We could not find anything. " + + "Try another keyword?\n"; + } + } + + static String printArchiveCompleted() { + return "Archived all commands in text file in your data folder!"; + } + + static String printRetrievalCompleted() { + return "Your archived commands have been added back to your current commands!"; + } +} diff --git a/src/main/java/sfx/464400__michael-grinnell__dog-bark.wav b/src/main/java/sfx/464400__michael-grinnell__dog-bark.wav new file mode 100644 index 0000000000..ce03a0fecf Binary files /dev/null and b/src/main/java/sfx/464400__michael-grinnell__dog-bark.wav differ diff --git a/src/main/resources/images/DaDukeDoge.jpg b/src/main/resources/images/DaDukeDoge.jpg new file mode 100644 index 0000000000..13b79f75aa Binary files /dev/null and b/src/main/resources/images/DaDukeDoge.jpg differ diff --git a/src/main/resources/images/DaUser.jpg b/src/main/resources/images/DaUser.jpg new file mode 100644 index 0000000000..79d74c0f3c Binary files /dev/null and b/src/main/resources/images/DaUser.jpg differ diff --git a/src/main/resources/style/DialogBox.css b/src/main/resources/style/DialogBox.css new file mode 100644 index 0000000000..2868277ab3 --- /dev/null +++ b/src/main/resources/style/DialogBox.css @@ -0,0 +1,13 @@ +.message { + -fx-font: 16px \"Segoe UI Symbol\"; + -fx-text-alignment: left; + -fx-background-color: #fdfd96; + -fx-background-radius: 20; + -fx-padding: 15; +} + +.layout { + -fx-padding: 10.0 10.0 10.0 10.0; +} + + diff --git a/src/main/resources/style/MainWindow.css b/src/main/resources/style/MainWindow.css new file mode 100644 index 0000000000..92419adb5a --- /dev/null +++ b/src/main/resources/style/MainWindow.css @@ -0,0 +1,11 @@ +.sendButton { + -fx-background-color: #e9c42e; +} + +.scroll-pane{ + -fx-background-color: #e5e5e5; +} + +.scroll-pane .viewport { + -fx-background-color: #e5e5e5; +} \ No newline at end of file diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml new file mode 100644 index 0000000000..4cdbe6b756 --- /dev/null +++ b/src/main/resources/view/DialogBox.fxml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml new file mode 100644 index 0000000000..3dd7df3939 --- /dev/null +++ b/src/main/resources/view/MainWindow.fxml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/duke/Command.html b/src/test/duke/Command.html new file mode 100644 index 0000000000..7b1f28ccc8 --- /dev/null +++ b/src/test/duke/Command.html @@ -0,0 +1,352 @@ + + + + + +Command + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Command

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.Command
    • +
    +
  • +
+
+
    +
  • +
    +
    Direct Known Subclasses:
    +
    Deadline, Event, ToDo
    +
    +
    +
    public class Command
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Command​(java.lang.String commandDescription) 
      +
    • +
    +
    + +
    + +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Command

        +
        public Command​(java.lang.String commandDescription)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        markDone

        +
        public Command markDone()
        +
      • +
      + + + +
        +
      • +

        getDescription

        +
        public java.lang.String getDescription()
        +
      • +
      + + + +
        +
      • +

        getDone

        +
        public java.lang.String getDone()
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class java.lang.Object
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/CommandList.html b/src/test/duke/CommandList.html new file mode 100644 index 0000000000..3b13205a57 --- /dev/null +++ b/src/test/duke/CommandList.html @@ -0,0 +1,279 @@ + + + + + +CommandList + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class CommandList

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.CommandList
    • +
    +
  • +
+
+
    +
  • +
    +
    public class CommandList
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    + +
    + +
    +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CommandList

        +
        public CommandList​(Storage storage,
        +                   java.util.ArrayList<Command> commands)
        +
      • +
      + + + +
        +
      • +

        CommandList

        +
        public CommandList​(Storage storage)
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/Deadline.html b/src/test/duke/Deadline.html new file mode 100644 index 0000000000..f591bc811f --- /dev/null +++ b/src/test/duke/Deadline.html @@ -0,0 +1,376 @@ + + + + + +Deadline + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Deadline

+
+
+
    +
  • java.lang.Object
  • +
  • + +
  • +
+
+
    +
  • +
    +
    public class Deadline
    +extends Command
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFieldDescription
      java.time.LocalDatedueDate 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Deadline​(java.lang.String commandDescription, + java.time.LocalDate dueDate) 
      +
    • +
    +
    + +
    + +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        dueDate

        +
        public java.time.LocalDate dueDate
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Deadline

        +
        public Deadline​(java.lang.String commandDescription,
        +                java.time.LocalDate dueDate)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getTime

        +
        public java.time.LocalDate getTime()
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class Command
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ + + + diff --git a/src/test/duke/Duke.html b/src/test/duke/Duke.html new file mode 100644 index 0000000000..071aa77b6e --- /dev/null +++ b/src/test/duke/Duke.html @@ -0,0 +1,302 @@ + + + + + +Duke + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Duke

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.Duke
    • +
    +
  • +
+
+
    +
  • +
    +
    public class Duke
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Duke() 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static voidmain​(java.lang.String[] args) 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Duke

        +
        public Duke()
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        main

        +
        public static void main​(java.lang.String[] args)
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/DukeException.html b/src/test/duke/DukeException.html new file mode 100644 index 0000000000..2f246c1788 --- /dev/null +++ b/src/test/duke/DukeException.html @@ -0,0 +1,289 @@ + + + + + +DukeException + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class DukeException

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • java.lang.Throwable
    • +
    • +
        +
      • java.lang.Exception
      • +
      • +
          +
        • duke.DukeException
        • +
        +
      • +
      +
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    java.io.Serializable
    +
    +
    +
    public class DukeException
    +extends java.lang.Exception
    +
    +
    See Also:
    +
    Serialized Form
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      DukeException​(java.lang.String errorMsg) 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Throwable

        +addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DukeException

        +
        public DukeException​(java.lang.String errorMsg)
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/DukeTest.html b/src/test/duke/DukeTest.html new file mode 100644 index 0000000000..684676ba39 --- /dev/null +++ b/src/test/duke/DukeTest.html @@ -0,0 +1,264 @@ + + + + + +DukeTest + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class DukeTest

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.DukeTest
    • +
    +
  • +
+
+
    +
  • +
    +
    public class DukeTest
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      DukeTest() 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DukeTest

        +
        public DukeTest()
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/Event.html b/src/test/duke/Event.html new file mode 100644 index 0000000000..4686875019 --- /dev/null +++ b/src/test/duke/Event.html @@ -0,0 +1,376 @@ + + + + + +Event + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Event

+
+
+
    +
  • java.lang.Object
  • +
  • + +
  • +
+
+
    +
  • +
    +
    public class Event
    +extends Command
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFieldDescription
      java.time.LocalDateeventDate 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Event​(java.lang.String commandDescription, + java.time.LocalDate eventDate) 
      +
    • +
    +
    + +
    + +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        eventDate

        +
        public java.time.LocalDate eventDate
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Event

        +
        public Event​(java.lang.String commandDescription,
        +             java.time.LocalDate eventDate)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getTime

        +
        public java.time.LocalDate getTime()
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class Command
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ + + + diff --git a/src/test/duke/Parser.html b/src/test/duke/Parser.html new file mode 100644 index 0000000000..c759c9119d --- /dev/null +++ b/src/test/duke/Parser.html @@ -0,0 +1,311 @@ + + + + + +Parser + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Parser

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.Parser
    • +
    +
  • +
+
+
    +
  • +
    +
    public class Parser
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Parser​(duke.CommandList commandList) 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidparseAll() +
      Introduces scanner class to read in input + and sorts input into appropriate parsing commands + +// * @exception Exception if unchecked exceptions appear, not ideally
      +
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Parser

        +
        public Parser​(duke.CommandList commandList)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        parseAll

        +
        public void parseAll()
        +
        Introduces scanner class to read in input + and sorts input into appropriate parsing commands + +// * @exception Exception if unchecked exceptions appear, not ideally
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/Storage.html b/src/test/duke/Storage.html new file mode 100644 index 0000000000..8e7a2a711d --- /dev/null +++ b/src/test/duke/Storage.html @@ -0,0 +1,375 @@ + + + + + +Storage + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Storage

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.Storage
    • +
    +
  • +
+
+
    +
  • +
    +
    public class Storage
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeFieldDescription
      java.lang.StringfilePath 
      java.nio.file.Pathpath 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Storage() 
      Storage​(java.lang.String filePath, + java.nio.file.Path path) 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + +
      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidcheckPath​(java.lang.String filePath, + java.nio.file.Path path) 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        filePath

        +
        public java.lang.String filePath
        +
      • +
      + + + +
        +
      • +

        path

        +
        public java.nio.file.Path path
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Storage

        +
        public Storage()
        +
      • +
      + + + +
        +
      • +

        Storage

        +
        public Storage​(java.lang.String filePath,
        +               java.nio.file.Path path)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        checkPath

        +
        public void checkPath​(java.lang.String filePath,
        +                      java.nio.file.Path path)
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ + + + diff --git a/src/test/duke/ToDo.html b/src/test/duke/ToDo.html new file mode 100644 index 0000000000..e70bfeb810 --- /dev/null +++ b/src/test/duke/ToDo.html @@ -0,0 +1,318 @@ + + + + + +ToDo + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class ToDo

+
+
+
    +
  • java.lang.Object
  • +
  • + +
  • +
+
+
    +
  • +
    +
    public class ToDo
    +extends Command
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      ToDo​(java.lang.String commandDescription) 
      +
    • +
    +
    + +
    + +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ToDo

        +
        public ToDo​(java.lang.String commandDescription)
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        toString

        +
        public java.lang.String toString()
        +
        +
        Overrides:
        +
        toString in class Command
        +
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/Ui.html b/src/test/duke/Ui.html new file mode 100644 index 0000000000..9689887f51 --- /dev/null +++ b/src/test/duke/Ui.html @@ -0,0 +1,302 @@ + + + + + +Ui + + + + + + + + + + + + + + +
+ +
+ +
+
+
Package duke
+

Class Ui

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • duke.Ui
    • +
    +
  • +
+
+
    +
  • +
    +
    public class Ui
    +extends java.lang.Object
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ConstructorDescription
      Ui() 
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + +
      All Methods Static Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static voidprintGreeting() 
      +
        +
      • + + +

        Methods inherited from class java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
    +
  • +
+
+
+
    +
  • + +
    +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Ui

        +
        public Ui()
        +
      • +
      +
    • +
    +
    + +
    +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        printGreeting

        +
        public static void printGreeting()
        +
      • +
      +
    • +
    +
    +
  • +
+
+
+
+ +
+ +
+ + diff --git a/src/test/duke/package-summary.html b/src/test/duke/package-summary.html new file mode 100644 index 0000000000..9f26ed4d8b --- /dev/null +++ b/src/test/duke/package-summary.html @@ -0,0 +1,162 @@ + + + + + +duke + + + + + + + + + + + + + + +
+ +
+
+
+

Package duke

+
+
+
    +
  • + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    Ui 
    +
  • +
+
+
+
+ +
+ + diff --git a/src/test/duke/package-tree.html b/src/test/duke/package-tree.html new file mode 100644 index 0000000000..cde07b688f --- /dev/null +++ b/src/test/duke/package-tree.html @@ -0,0 +1,155 @@ + + + + + +duke Class Hierarchy + + + + + + + + + + + + + + +
+ +
+
+
+

Hierarchy For Package duke

+
+
+
+

Class Hierarchy

+
    +
  • java.lang.Object +
      +
    • duke.Ui
    • +
    +
  • +
+
+
+
+ + + diff --git a/src/test/java/DeadlineTest.java b/src/test/java/DeadlineTest.java new file mode 100644 index 0000000000..c27c66f1cd --- /dev/null +++ b/src/test/java/DeadlineTest.java @@ -0,0 +1,23 @@ +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalDate; + +import org.junit.jupiter.api.Test; + +import duke.Deadline; + +public class DeadlineTest { + @Test + public void toStringTest() { + LocalDate parseDate = LocalDate.parse("2021-01-11"); + Deadline deadline = new Deadline("test", parseDate); + assertEquals(deadline.toString(), "[D] [ ] test | by: 11 Jan 2021"); + } + + @Test + public void getTimeTest() { + LocalDate parseDate = LocalDate.parse("2021-01-11"); + Deadline deadline = new Deadline("test", parseDate); + assertEquals(deadline.getTime(), parseDate); + } +} diff --git a/src/test/java/DukeTest.java b/src/test/java/DukeTest.java new file mode 100644 index 0000000000..2408d7d029 --- /dev/null +++ b/src/test/java/DukeTest.java @@ -0,0 +1,10 @@ +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class DukeTest { + @Test + public void dummyTest() { + assertEquals(2, 2); + } +} diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index 657e74f6e7..e89f6589f5 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,7 +1,87 @@ -Hello from - ____ _ -| _ \ _ _| | _____ -| | | | | | | |/ / _ \ -| |_| | |_| | < __/ -|____/ \__,_|_|\_\___| +Greetings from +░▄▀▄▀▀▀▀▄▀▄░░░░░░░░░ +░█░░░░░░░░▀▄░░░░░░▄░ +█░░▀░░▀░░░░░▀▄▄░░█░█ +█░▄░█▀░▄░░░░░░░▀▀░░█ +█░░▀▀▀▀░░░░░░░░░░░░█ +█░░░░░░░░░░░░░░░░░░█ +█░░░░░░░░░░░░░░░░░░█ +░█░░▄▄░░▄▄▄▄░░▄▄░░█░ +░█░▄▀█░▄▀░░█░▄▀█░▄▀░ +░░▀░░░▀░░░░░▀░░░▀░░░ + +____________________________________________________________ +Woof! I'm Doge Duke +What do you want me to do? +Type your request in below! + +____________________________________________________________ + +duke.DukeException: Whoops :( I'm sorry, I'm not sure what that means. Did you forget to add a command type? + +____________________________________________________________ +Mlem I've added a new command for you to do: +[T] [ ] rollover +Now I can do a total of 1 commands! +____________________________________________________________ + +This date doesnt exist! The right format should be in yyyy-mm-dd. + +____________________________________________________________ +Much wow! I've added a new command with an Event: +[E] [ ] dog festival | at: 10 Feb 2021 +Now I can do a total of 2 commands! +____________________________________________________________ + + +____________________________________________________________ +Woofers! I've added a new command with a Ded-line: +[D] [ ] finish doggo treats | by: 11 Mar 2021 +Now I can do a total of 3 commands! +____________________________________________________________ + +duke.DukeException: Whoops :( I'm sorry, I'm not sure what that means. Did you forget to add a command type? + +____________________________________________________________ +Very Woof! I have completed this commands: +[T] [X] rollover + +____________________________________________________________ + +duke.DukeException: Eh? Your command description cannot be empty. Try again! + +____________________________________________________________ +Very Woof! I have completed this commands: +[D] [X] finish doggo treats | by: 11 Mar 2021 + +____________________________________________________________ + + +____________________________________________________________ +We found some matching commands: +1. [E] [ ] dog festival | at: 10 Feb 2021 +2. [D] [X] finish doggo treats | by: 11 Mar 2021 + +____________________________________________________________ + +duke.DukeException: What are you referring to? Remember to key in the correct command id! + +____________________________________________________________ +Noted! This task has been removed: +[E] [ ] dog festival | at: 10 Feb 2021 +Now you have 2 commands remaining. +____________________________________________________________ + + +____________________________________________________________ + +1. [T] [X] rollover +2. [D] [X] finish doggo treats | by: 11 Mar 2021 + +____________________________________________________________ + + +____________________________________________________________ +Bye! Hope I was a good dog, see you again soon! +____________________________________________________________ diff --git a/text-ui-test/data/duke.txt b/text-ui-test/data/duke.txt new file mode 100644 index 0000000000..e64eb8ac9c --- /dev/null +++ b/text-ui-test/data/duke.txt @@ -0,0 +1,2 @@ +T | 1 | rollover +D | 1 | finish doggo treats | 2021-03-11 diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index e69de29bb2..a0d50ddae7 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -0,0 +1,14 @@ +paw +todo rollover +event dog festival /at 2021-020-10 +event dog festival /at 2021-02-10 +deadline finish doggo treats /by 2021-03-11 +shake +done 1 +todo +done 3 +find dog +delete +delete 2 +list +bye diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh old mode 100644 new mode 100755 index c9ec870033..54df5dad0f --- a/text-ui-test/runtest.sh +++ b/text-ui-test/runtest.sh @@ -13,14 +13,14 @@ then fi # compile the code into the bin folder, terminates if error occurred -if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/*.java +if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/duke/*.java then echo "********** BUILD FAILURE **********" exit 1 fi # 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 -cp ../bin duke.Duke < input.txt > ACTUAL.TXT # convert to UNIX format cp EXPECTED.TXT EXPECTED-UNIX.TXT