diff --git a/README.md b/README.md index 8715d4d915..336e432831 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,11 @@ -# Duke project template +# BMO Assistant -This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it. +This is a Software Engineering academic project done by using a greenfield Java project template, +[Duke](https://github.com/nus-cs2103-AY2122S2/ip). It is an application to help user keep track of tasks, deadlines +and events. Given below is the instruction for installing the application. -## Setting up in Intellij +### Setting up BMO Assistant -Prerequisites: JDK 11, update Intellij to the most recent version. - -1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first) -1. Open the project into Intellij as follows: - 1. Click `Open`. - 1. Select the project directory, and click `OK`. - 1. If there are any further prompts, accept the defaults. -1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).
- In the same dialog, set the **Project language level** field to the `SDK default` option. -3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output: - ``` - Hello from - ____ _ - | _ \ _ _| | _____ - | | | | | | | |/ / _ \ - | |_| | |_| | < __/ - |____/ \__,_|_|\_\___| - ``` +* Follow this [link](https://github.com/geetengtan/BMO-Assistant/releases/tag/A-Release) and install the duke.jar file + within the Assets. +* Refer to the [User Guide](https://geetengtan.github.io/BMO-Assistant/) to familiarise yourself with the application. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..4a8d6c1889 --- /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 { + 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' + + String javaFxVersion = '11' + + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' +} + +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/data/duke.txt b/data/duke.txt new file mode 100644 index 0000000000..9a0f153a9e --- /dev/null +++ b/data/duke.txt @@ -0,0 +1,3 @@ +T#true#borrow book +D#false#return book #2022-03-11 +D#false#CS2103 iP #2022-02-18 diff --git a/data/notes.txt b/data/notes.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 8077118ebe..0000000000 --- a/docs/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# User Guide - -## Features - -### Feature-ABC - -Description of the feature. - -### Feature-XYZ - -Description of the feature. - -## Usage - -### `Keyword` - Describe action - -Describe the action and its outcome. - -Example of usage: - -`keyword (optional arguments)` - -Expected outcome: - -Description of the outcome. - -``` -expected output -``` diff --git a/docs/Ui.png b/docs/Ui.png new file mode 100644 index 0000000000..a506bb2b13 Binary files /dev/null and b/docs/Ui.png differ diff --git a/docs/UserGuide.md b/docs/UserGuide.md new file mode 100644 index 0000000000..258d622a28 --- /dev/null +++ b/docs/UserGuide.md @@ -0,0 +1,204 @@ +# User Guide + +## Features +- Task List +- Personalised Notes + +### Task List + +Task List helps you organise your tasks, keep track of progress and can remind you of deadlines and events. + +### Personalised Notes + +Personalised Notes can help you record important stuffs that you might want to refer to any time. + +## Usage + +### `list` - view Task List + +The current Task List is printed. A task has the following format: +`[type of task][makred/unmarked] description (date of task)` + +Example of usage: + +`list` + +Expected outcome: + +``` +Here are the tasks in your list: + 1. [T][X] borrow book + 2. [D][ ] return book (Mar 11 2022) + 3. [D][ ] CS2103 iP (Feb 18 2022) + 4. [E][ ] party at Evan's (Feb 27 2022) +``` + + + +### `todo [description]` - add a todo task to Task List + +Add a todo task to your Task List. Todo task supports task description feature only. + +Example of usage: + +`todo borrow book` + +Expected outcome: + +A new task `todo` will be added to your Task List and labelled [T] for **T**odos. Todos support task description + +``` +Got it. BMO has added this task: + [T][ ] borrow book +Now you have 1 task in your list. +``` + + + +### `deadline [description] /[yyyy-mm-dd]` - add a deadline to Task List + +Example of usage: + +`deadline return book /2022-03-11` + +Expected outcome: + +A new task `deadline` will be added to your Task List and labelled [D] for **D**eadlines. Deadlines support task description and date + +``` +Got it. BMO has added this task: + [D][ ] return book (Feb 27 2022) +Now you have 2 tasks in your list. +``` + + + +### `event [description] /[yyyy-mm-dd]` - add an event to Task List + +Example of usage: + +`event party at Evan's /2022-02-27` + +Expected outcome: + +A new task `event` will be added to your Task List and labelled [E] for **E**vents. Events support task description and date. + +``` +Got it. BMO has added this task: + [E][ ] party at Evan's (Feb 27 2022) +Now you have 3 tasks in your list. +``` + + + +### `mark [index]` - mark a task + +Marks the task according to the index of the Task List. + +Example of usage: + +`mark 1` + +Expected outcome: + +The indexed task will be marked and shown. + +``` +Awesome! :D Another task done: + [T][X] borrow book +``` + + + +### `unmark [index]` - unmark a task + +Unmarks the task according to the index of the Task List. + +Example of usage: + +`unmark 1` + +Expected outcome: + +The indexed task will be unmarked and shown. + +``` +T_T BMO hate it when you lie. I will unmark this task: + [T][ ] borrow book +``` + + + +### `delete [index]` - delete a task + +Deletes the task according to the index of the Task List. + +Example of usage: + +`delete 1` + +Expected outcome: + +The indexed task will be unmarked and shown. + +``` +BMO deleted the task. Yay!: + [T][X] borrow book +``` + + + +### `note [label]: [description]` - add a new note to your Personalised Notes + +Adds a new note with a label and a description. Notes are referred to by their labels instead of index. + +Example of usage: + +`note StudentID: A0123456M` + +Expected outcome: + +New note added to Personalised Notes. `label` of the note is StudentID and `description` of the note is A0123456M. + +``` +BMO added this to your notes: + StudentID: A0123456M +``` + + + +### `checknote` - check your Personalised Notes + +Checks your Personalised Notes. + +Example of usage: + +`checknote` + +Expected outcome: + +The current list of Personalised Notes. + +``` +Here are your notes: + StudentID: A0123456M +``` + + + +### `deletenote [label]` - delete a note + +Deletes a note with the label given. + +Example of usage: + +`deletenote StudentID` + +Expected outcome: + +Note with label StudentID is deleted from Personalised Notes. + +``` +Deleted this note: + StudentID: A0123456M +``` \ No newline at end of file diff --git a/docs/download1.png b/docs/download1.png new file mode 100644 index 0000000000..a891e8c948 Binary files /dev/null and b/docs/download1.png differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..7454180f2a 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..eeef03d48d --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,11 @@ +#Wed Feb 02 12:10:36 MYT 2022 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip +distributionPath=wrapper/dists +<<<<<<< HEAD +======= +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +>>>>>>> branch-A-JavaDoc +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..1b6c787337 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original 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 POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${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 "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# 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 ;; #( + MSYS* | 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" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000000..107acd32c4 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@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 execute + +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 execute + +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 + +: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 %* + +: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/pom.xml b/pom.xml new file mode 100644 index 0000000000..b299f3b496 --- /dev/null +++ b/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + org.junit + junit + 5.6.0 + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + org.junit.jupiter + junit-jupiter-api + 5.8.1 + test + + + + + 11 + 11 + + + \ No newline at end of file diff --git a/src/main/java/DialogBox.java b/src/main/java/DialogBox.java new file mode 100644 index 0000000000..bc12a7d915 --- /dev/null +++ b/src/main/java/DialogBox.java @@ -0,0 +1,77 @@ +import java.io.IOException; +import java.util.Collections; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.effect.DropShadow; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.HBox; +import javafx.scene.paint.Color; +import javafx.scene.paint.Paint; +import javafx.scene.shape.Rectangle; + +/** + * 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; + @FXML + private Rectangle rect; + + private DialogBox(String text, Image img, Paint color) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml")); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + fxmlLoader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + DropShadow dropShadow = new DropShadow(); + dropShadow.setRadius(0.5); + dropShadow.setOffsetX(1); + dropShadow.setOffsetY(1); + dropShadow.setColor(Color.color(0.4, 0.5, 0.5)); + + dialog.setText(text); + dialog.setBackground(new Background(new BackgroundFill(color, new CornerRadii(5.0), Insets.EMPTY))); + dialog.setEffect(dropShadow); + displayPicture.setImage(img); + } + + /** + * Flips the dialog box such that the ImageView is on the left and text on the right. + */ + private void flip() { + ObservableList tmp = FXCollections.observableArrayList(this.getChildren()); + Collections.reverse(tmp); + getChildren().setAll(tmp); + setAlignment(Pos.TOP_LEFT); + } + + public static DialogBox getUserDialog(String text, Image img) { + return new DialogBox(text, img, Paint.valueOf("#6dc686")); + } + + public static DialogBox getDukeDialog(String text, Image img) { + var db = new DialogBox(text, img, Paint.valueOf("#FFFFFF")); + 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..11dbf00c62 --- /dev/null +++ b/src/main/java/Launcher.java @@ -0,0 +1,10 @@ +import javafx.application.Application; + +/** + * A launcher class to workaround classpath issues. + */ +public class Launcher { + public static void main(String[] args) { + Application.launch(Main.class, args); + } +} \ No newline at end of file diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..19e86fe56e --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: seedu.duke.Duke + diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000000..aaa4f90db7 --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,35 @@ +import java.io.IOException; + +import duke.Duke; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.image.Image; +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("duke.txt", "notes.txt"); + + @Override + public void start(Stage stage) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml")); + AnchorPane ap = fxmlLoader.load(); + Scene scene = new Scene(ap); + stage.setScene(scene); + stage.setTitle("BMO Assistant"); + stage.setResizable(false); + stage.getIcons().add(new Image("/images/BMO2.png")); + 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..edc45fb849 --- /dev/null +++ b/src/main/java/MainWindow.java @@ -0,0 +1,81 @@ +import duke.Command; +import javafx.application.Platform; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.scene.control.Button; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.layout.*; + +import duke.Duke; +import javafx.scene.paint.Paint; + +/** + * 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/UserPic3.png")); + private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/BMO2.png")); + + @FXML + public void initialize() { + scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); + } + + public void setDuke(Duke d) { + duke = d; + String startMsg = duke.startDuke(); + dialogContainer.getChildren().addAll( + DialogBox.getDukeDialog(startMsg, 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() { + String input = userInput.getText(); + String response = duke.getResponse(input); + dialogContainer.getChildren().addAll( + DialogBox.getUserDialog(input, userImage), + DialogBox.getDukeDialog(response, dukeImage) + ); + userInput.clear(); + + if (input.equals("bye")) { + duke.saveDuke(); + waitAndThenExit(); + } + + } + + /** + * Waits for a moment and then exit the program + */ + private void waitAndThenExit() { + new Thread(() -> { + try { + Thread.sleep(2000); + } catch (InterruptedException exc) { + System.out.println("Exit operation interrupted"); + System.out.println(exc); + } + + Platform.exit(); + }).start(); + } +} \ No newline at end of file diff --git a/src/main/java/duke/Command.java b/src/main/java/duke/Command.java new file mode 100644 index 0000000000..59db0de5d0 --- /dev/null +++ b/src/main/java/duke/Command.java @@ -0,0 +1,8 @@ +package duke; + +public enum Command { + + + LIST, TODO, DEADLINE, EVENT, MARK, UNMARK, DELETE, FIND, BYE, HELLO, NOTE, CHECKNOTE, DELETENOTE, HELP + +} diff --git a/src/main/java/duke/Deadline.java b/src/main/java/duke/Deadline.java new file mode 100644 index 0000000000..064e5428f2 --- /dev/null +++ b/src/main/java/duke/Deadline.java @@ -0,0 +1,35 @@ +package duke; + +import java.time.LocalDate; + +/** + * A Task that specifies the date required for the task to be completed. Supports Task description and time + */ + +public class Deadline extends Task { + + Deadline(String description, LocalDate deadline) { + super(description, deadline); + } + + Deadline(String description, boolean isDone, LocalDate deadline) { + super(description, isDone, deadline); + } + + @Override + public String toString() { + assert time.isPresent() : "time of deadline not available"; + + String doneIndicator; + if (isDone) { + doneIndicator = "X"; + } else { + doneIndicator = " "; + } + + return "[D][" + doneIndicator + "] " + + description + + "(" + time.get().format(DATE_FORMATTER) + ")"; + } + +} diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java new file mode 100644 index 0000000000..f4f9fa5e01 --- /dev/null +++ b/src/main/java/duke/Duke.java @@ -0,0 +1,47 @@ +package duke; + +/** + * Main executable for the Duke program. + */ + +public class Duke { + + + private Storage taskStorage; + private Storage noteStorage; + private TaskList tasks; + private NoteList notes; + private Ui ui; + + + public Duke(String taskListFilePath, String notesFilePath) { + ui = new Ui(); + taskStorage = new Storage(taskListFilePath); + noteStorage = new Storage(notesFilePath); + + try { + tasks = new TaskList(taskStorage.loadTaskList()); + notes = new NoteList(noteStorage.loadNoteList()); + } catch (Exception e) { + ui.showLoadingError(); + System.out.println(e); + tasks = new TaskList(); + notes = new NoteList(); + } + + } + + public void saveDuke() { + taskStorage.saveTasks(tasks); + noteStorage.saveNotes(notes); + } + + public String startDuke() { + return ui.getStartOutput(); + } + + public String getResponse(String input) { + return ui.getDukeOutput(input, tasks, notes); + } + +} diff --git a/src/main/java/duke/DukeAbsentInfoException.java b/src/main/java/duke/DukeAbsentInfoException.java new file mode 100644 index 0000000000..99acbd36fc --- /dev/null +++ b/src/main/java/duke/DukeAbsentInfoException.java @@ -0,0 +1,9 @@ +package duke; + +public class DukeAbsentInfoException extends DukeException { + + DukeAbsentInfoException(String message) { + super(message); + } + +} diff --git a/src/main/java/duke/DukeException.java b/src/main/java/duke/DukeException.java new file mode 100644 index 0000000000..1ed75a439c --- /dev/null +++ b/src/main/java/duke/DukeException.java @@ -0,0 +1,16 @@ +package duke; + +public class DukeException extends Exception { + + String message; + + DukeException(String message) { + this.message = message; + } + + @Override + public String toString() { + return message; + } + +} diff --git a/src/main/java/duke/DukeIdxOOBException.java b/src/main/java/duke/DukeIdxOOBException.java new file mode 100644 index 0000000000..f7788aafec --- /dev/null +++ b/src/main/java/duke/DukeIdxOOBException.java @@ -0,0 +1,9 @@ +package duke; + +public class DukeIdxOOBException extends DukeException { + + DukeIdxOOBException() { + super("☹ OOPS!!! The index specified is out of bounds."); + } + +} diff --git a/src/main/java/duke/Event.java b/src/main/java/duke/Event.java new file mode 100644 index 0000000000..695a66205a --- /dev/null +++ b/src/main/java/duke/Event.java @@ -0,0 +1,35 @@ +package duke; + +import java.time.LocalDate; + +/** + * A Task that specifies a date of occurrence. Supports Task description and time + */ +public class Event extends Task { + + Event(String description, LocalDate time) { + super(description, time); + } + + Event(String description, boolean isDone, LocalDate time) { + super(description, isDone, time); + } + + @Override + public String toString() { + assert time.isPresent() : "time of event not available"; + + String doneIndicator; + if (isDone) { + doneIndicator = "X"; + } else { + doneIndicator = " "; + } + + return "[E][" + + doneIndicator + "] " + + description + "(" + + time.get().format(DATE_FORMATTER) + ")"; + } +} + diff --git a/src/main/java/duke/Note.java b/src/main/java/duke/Note.java new file mode 100644 index 0000000000..50d9d77b2e --- /dev/null +++ b/src/main/java/duke/Note.java @@ -0,0 +1,26 @@ +package duke; + +public class Note { + + private final String label; + private final String description; + + Note(String label, String description) { + this.label = label; + this.description = description; + } + + public String getLabel() { + return label; + } + + public String getDescription() { + return description; + } + + @Override + public String toString() { + return label + ": " + description; + } + +} diff --git a/src/main/java/duke/NoteList.java b/src/main/java/duke/NoteList.java new file mode 100644 index 0000000000..05cb70daa4 --- /dev/null +++ b/src/main/java/duke/NoteList.java @@ -0,0 +1,58 @@ +package duke; + +import java.util.ArrayList; + +public class NoteList { + + private static final String NOTE_HEADER = "Here are your notes: \n"; + private static final String NOTE_EMPTY_MESSAGE = "Seems like you don't have any notes yet\n\n" + + "Use command \"note [keyword]: [description]\" to add new notes"; + + private final ArrayList notes; + + NoteList() { + notes = new ArrayList<>(); + } + + NoteList(ArrayList notes) { + this.notes = new ArrayList<>(notes); + } + + public ArrayList getNotes() { + return notes; + } + + public String add(Note note) { + notes.add(note); + + return "BMO added this to your notes: \n " + note; + } + + public String delete(String key) { + for (int i = 0; i < notes.size(); i++) { + if (notes.get(i).getLabel().equals(key)) { + return "Deleted this note: \n " + notes.remove(i); + } + } + + return "Cannot find note with same key to delete."; + } + + public String makeNoteList() { + StringBuilder bld = new StringBuilder(); + for (Note n : notes) { + bld.append(" "); + bld.append(n); + bld.append("\n"); + } + + return bld.toString(); + } + + public String checkNotes() { + if (notes.isEmpty()) { + return NOTE_EMPTY_MESSAGE; + } + return NOTE_HEADER + makeNoteList(); + } +} diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java new file mode 100644 index 0000000000..6b00bd0bbc --- /dev/null +++ b/src/main/java/duke/Parser.java @@ -0,0 +1,142 @@ +package duke; +import java.time.LocalDate; +import java.util.Locale; + +/** + * Parser for the Duke that includes static methods to interpret user inputs. + * Also includes a method to parse and read save files. + */ +public class Parser { + + /** + * Reads the String input and determines the type of command to execute and returns it as an integer + * + * @param input User input for the Duke program + * @return An integer to represent the type of command to execute + * @throws DukeException When String input doesn't match any type of command + */ + public static Command getCommand(String input) throws DukeException { + String str = input.split(" ", 2)[0].toLowerCase(); + + switch (str) { + case "list": + return Command.LIST; + case "todo": + return Command.TODO; + case "deadline": + return Command.DEADLINE; + case "event": + return Command.EVENT; + case "mark": + return Command.MARK; + case "unmark": + return Command.UNMARK; + case "delete": + return Command.DELETE; + case "find": + return Command.FIND; + case "bye": + return Command.BYE; + case "hello": + return Command.HELLO; + case "note": + return Command.NOTE; + case "checknote": + return Command.CHECKNOTE; + case "deletenote": + return Command.DELETENOTE; + case "help": + return Command.HELP; + default: + throw new DukeException("Hmm BMO doesn't understand what that means..."); + } + + } + + /** + * Reads the String input and returns the description of the Task according to the input line + * + * @param input User input for the Duke program + * @return The description of the Task of the user input + * @throws DukeException If Task description not specified correctly. + */ + public static String getDescription(String input) throws DukeException { + try { + return input.split(" ", 2)[1].split("/", 2)[0]; + } catch (Exception e) { + throw new DukeAbsentInfoException("Description of task not specified, \n" + + "eg. todo [description]"); + } + + } + + /** + * Reads the String input and returns the index to apply the command + * + * @param input User input for the Duke program. + * @return The index of the Task to apply the command. + * @throws DukeException If parsing of the String input fails. + */ + public static int getIndex(String input) throws DukeException { + try { + return Integer.parseInt(input.split(" ", 2)[1].split("/", 2)[0]); + } catch (Exception e) { + throw new DukeException("description parsing problem"); + } + + } + + /** + * Reads the String input and returns the date of the Task according to the input line + * + * @param input User input for the Duke program. + * @return The date of the Task of the user input + * @throws DukeException If date provided is not in correct format ([task] [description]/yyyy-mm-dd) + */ + public static LocalDate getDate(String input) throws DukeException { + try { + return LocalDate.parse(input.split(" ", 2)[1].split("/", 2)[1]); + } catch (Exception e) { + throw new DukeException("Date not provided or not specified in correct format ([task] [description]/yyyy-mm-dd)"); + } + + } + + /** + * Returns a Task that is derived from the input String + * + * @param input String inputs from the save file. + * @return Task corresponding to the given line of input. + * @throws DukeException If the input line is not is the correct save format. + */ + public static Task getTask(String input) throws DukeException { + + String[] stringArr = input.split("#"); + + switch (stringArr[0]) { + case "T": + return new ToDo(stringArr[2], stringArr[1].equals("true")); + case "D": + return new Deadline(stringArr[2], stringArr[1].equals("true"), LocalDate.parse(stringArr[3])); + case "E": + return new Event(stringArr[2], stringArr[1].equals("true"), LocalDate.parse(stringArr[3])); + default: + throw new DukeException("Problem retrieving files from data"); + + } + + } + + public static Note getNote(String input) throws DukeException { + + String[] stringArr = input.split(": "); + + if (stringArr.length < 2) { + throw new DukeAbsentInfoException("Please provide notes in the following format: " + + "note [keyword]: [description]"); + } + + return new Note(stringArr[0], stringArr[1]); + } + +} diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java new file mode 100644 index 0000000000..59efec0aef --- /dev/null +++ b/src/main/java/duke/Storage.java @@ -0,0 +1,155 @@ +package duke; + +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.io.File; +import java.util.Scanner; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.Files; + +/** + * A class to manage the saving and loading of files in the Duke program + */ +public class Storage { + + private final Path filepath; + private final Path directory; + + Storage(String file) { + String home = System.getProperty("user.home"); + + this.filepath = Paths.get(home, "data", file); + this.directory = Paths.get(home, "data"); + } + + /** + * Reads the save file from this.filepath and returns an ArrayList that represents the save file. + * + * @return ArrayList that represents the save file. + * @throws DukeException If the duke.txt file doesn't exist. + */ + public ArrayList loadTaskList() throws DukeException { + try { + + Scanner sc = new Scanner(this.filepath); + ArrayList tasks = new ArrayList<>(); + + while(sc.hasNext()) { + tasks.add(Parser.getTask(sc.nextLine())); + } + + sc.close(); + + return tasks; + + } catch (IOException e) { + + throw new DukeException("Problem loading data"); + + } + } + + public ArrayList loadNoteList() throws DukeException { + try { + + Scanner sc = new Scanner(this.filepath); + ArrayList notes = new ArrayList<>(); + + while(sc.hasNext()) { + notes.add(Parser.getNote(sc.nextLine())); + } + + sc.close(); + + return notes; + } catch (IOException e) { + + throw new DukeException("Problem loading data"); + + } + } + + /** + * Takes in a list of tasks and save them in a duke.txt file. + * If duke.txt file already exists, the new save will overwrite the existing one. + * + * @param tasks List of tasks + */ + public void saveTasks(TaskList tasks) { + + String saveFormat = ""; + + for (Task t : tasks.getTasks()) { + if (t instanceof ToDo) { + saveFormat += "T#"; + saveFormat += t.isDone ? "true" : "false"; + saveFormat += "#" + t.description + "\n"; + continue; + } else if (t instanceof Deadline) { + saveFormat += "D"; + } else if (t instanceof Event) { + saveFormat += "E"; + } + saveFormat += "#"; + + saveFormat += t.isDone ? "true" : "false"; + saveFormat += "#"; + + saveFormat += t.description; + saveFormat += "#"; + + saveFormat += t.time.get(); + saveFormat += "\n"; + } + + try { + + if (!Files.exists(this.directory)) { + Files.createDirectories(this.directory); + } + + if (!Files.exists(this.filepath)) { + Files.createFile(this.filepath); + } + + File f = this.filepath.toFile(); + + FileWriter fw = new FileWriter(f); + fw.write(saveFormat); + fw.close(); + } catch (Exception e) { + System.out.println("Error while saving file.\n" + e); + } + } + + public void saveNotes(NoteList notes) { + + String saveFormattedNotes = ""; + + for (Note n : notes.getNotes()) { + saveFormattedNotes += n + "\n"; + } + + try { + + if (!Files.exists(this.directory)) { + Files.createDirectories(this.directory); + } + + if (!Files.exists(this.filepath)) { + Files.createFile(this.filepath); + } + + File f = this.filepath.toFile(); + + FileWriter fw = new FileWriter(f); + fw.write(saveFormattedNotes); + fw.close(); + + } catch (Exception e) { + System.out.println("Error while saving file.\n" + e); + } + } +} diff --git a/src/main/java/duke/Task.java b/src/main/java/duke/Task.java new file mode 100644 index 0000000000..600b3b2719 --- /dev/null +++ b/src/main/java/duke/Task.java @@ -0,0 +1,59 @@ +package duke; + +import java.util.Optional; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +/** + * A skeleton for Tasks + */ +public abstract class Task { + + protected static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("LLL dd yyyy"); + + protected boolean isDone; + protected String description; + protected Optional time; + + Task(String description) { + this.description = description; + this.isDone = false; + this.time = Optional.empty(); + } + + Task(String description, boolean isDone) { + this.description = description; + this.isDone = isDone; + this.time = Optional.empty(); + } + + Task(String description, LocalDate time) { + this.description = description; + this.time = Optional.of(time); + } + + Task(String description, boolean isDone, LocalDate time) { + this.description = description; + this.isDone = isDone; + this.time = Optional.of(time); + } + + public void mark() { + isDone = true; + } + + public void unmark() { + isDone = false; + } + + @Override + public String toString() { + String doneIndicator = " "; + + if (isDone) { + doneIndicator = "X"; + } + + return "[" + doneIndicator + "] " + description; + } +} diff --git a/src/main/java/duke/TaskList.java b/src/main/java/duke/TaskList.java new file mode 100644 index 0000000000..53c86ce1df --- /dev/null +++ b/src/main/java/duke/TaskList.java @@ -0,0 +1,168 @@ +package duke; + +import java.util.ArrayList; + +/** + * A container for Task. + * Provides methods to manipulate list of Task in it. + */ +public class TaskList { + + private final ArrayList tasks; + + TaskList() { + this.tasks = new ArrayList<>(); + } + + TaskList(ArrayList tasks) { + this.tasks = new ArrayList<>(tasks); + } + + public ArrayList getTasks() { + return tasks; + } + + /** + * Adds a Task into the TaskList and returns a message to indicate success + * + * @param t Task to be added + * @return Message for successfully adding a Task + */ + public String add(Task t) { + tasks.add(t); + + return "Got it. BMO has added this task:\n " + t + count(); + } + + /** + * Returns a String to represent the current list of Tasks + * + * @return Current list of Tasks + */ + public String list() { + String tempStr = "Here are the tasks in your list:\n "; + for (int i = 0; i < tasks.size(); i++) { + if (i != 0) { + tempStr += "\n "; + } + tempStr += (i + 1) + ". " + tasks.get(i); + } + + return tempStr; + } + + /** + * Marks the Task according to the index provided and returns a message for successfully marking the Task + * + * @param idx index of the Task to be marked + * @return Message for successfully marking the Task + * @throws DukeException If the index specified is out of bounds OR If the TaskList is empty + */ + public String mark(int idx) throws DukeException { + + if (idx < 1 || idx > tasks.size()) { + throw new DukeIdxOOBException(); + } + + tasks.get(idx - 1).mark(); + + return "Awesome! :D Another task done:\n " + tasks.get(idx - 1); + + } + + /** + * Unmasks the Task according to the index provided and returns a message for successfully unmaking the Task + * + * @param idx index of the Task to be unmarked + * @return Message for successfully unmaking the Task + * @throws DukeException If the index specified is out of bounds OR If the TaskList is empty + */ + public String unmark(int idx) throws DukeException { + + if (idx < 1 || idx > tasks.size()) { + throw new DukeIdxOOBException(); + } + + tasks.get(idx - 1).unmark(); + + return "T_T BMO hate it when you lie. I will unmark this task:\n " + tasks.get(idx - 1); + + } + + /** + * Deletes the Task according to the index provided and returns a message for successfully deleting the Task + * + * @param idx index of the Task to be deleted + * @return Message for successfully deleting the Task + * @throws DukeException If the index specified is out of bounds OR If the TaskList is empty + */ + public String delete(int idx) throws DukeException { + + if (tasks.size() == 0) { + throw new DukeException("BMO don't think you have anything to delete :\\"); + } + + if (idx < 1 || idx > tasks.size()) { + throw new DukeIdxOOBException(); + } + + return "BMO deleted the task. Yay!:\n " + tasks.remove(idx - 1) + count(); + + } + + /** + * Returns a string that describes the number of tasks in the list + * + * @return String that describes the number of tasks in the TaskList + */ + public String count() { + String isSingular = "s"; + + if (tasks.size() == 1) { + isSingular = ""; + } + + return "\nNow you have " + tasks.size() + " task" + isSingular + " in your list."; + } + + /** + * Finds tasks that contain the keyword in their description to return a list, else returns a message + * to inform failure of doing so + * + * @param keyword a String or Char sequence to be searched for + * @return a list of tasks containing the keyword in String format or a message to imply failure + */ + public String find(String keyword) { + String resultStr = ""; + boolean isFound = false; + int i = 1; + String lowerCasedKeyword = keyword.toLowerCase(); + + for (Task t : this.tasks) { + if (t.description.toLowerCase().contains(lowerCasedKeyword)) { + isFound = true; + resultStr += i++ + ". " + t + "\n "; + } + } + + if (isFound) { + resultStr = "Here are the matching tasks in your list:\n " + resultStr; + } else { + resultStr = "No matching results found in the list."; + } + + return resultStr; + } + + /** + * @return exit message + */ + public String exit() { + return "Bye bye. BMO will see you again soon ' v '"; + } + + public String greet() { + return "Hello :D"; + } + +} diff --git a/src/main/java/duke/ToDo.java b/src/main/java/duke/ToDo.java new file mode 100644 index 0000000000..9c39ce49ca --- /dev/null +++ b/src/main/java/duke/ToDo.java @@ -0,0 +1,31 @@ +package duke; + +/** + * A simple Task object, supports Task description + */ +public class ToDo extends Task { + + ToDo(String description) { + super(description); + } + + ToDo(String description, boolean isDone) { + super(description, isDone); + } + + @Override + public String toString() { + assert time.isPresent() : "time of Deadline not found"; + + String doneIndicator = " "; + if (isDone) { + doneIndicator = "X"; + } else { + doneIndicator = " "; + } + + return "[T][" + doneIndicator + "] " + + description; + } + +} \ No newline at end of file diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java new file mode 100644 index 0000000000..8cb0c2e0c2 --- /dev/null +++ b/src/main/java/duke/Ui.java @@ -0,0 +1,87 @@ +package duke; + +/** + * The user interface. + * Interacts with user to receive inputs and print outputs. + */ +public class Ui { + + private static final String OUTPUT_ERROR_MSG = "OOPS BMO cannot generate an appropriate output x_x"; + private static final String START_MSG = "BMO is back online ^-^ \nHow can I help you?"; + + /** + * Prints an error message for failure in loading files + */ + public void showLoadingError() { + System.out.println("Failed to retrieve data from storage"); + } + + /** + * Interprets the user input and returns output according to them + * + * @param input User input + * @param tasks Current TaskList in the Duke program + */ + public String getDukeOutput(String input, TaskList tasks, NoteList notes) { + try { + Command cmd = Parser.getCommand(input); + + switch (cmd) { + case LIST: + return tasks.list(); + case TODO: + return tasks.add(new ToDo(Parser.getDescription(input))); + case DEADLINE: + return tasks.add(new Deadline(Parser.getDescription(input), Parser.getDate(input))); + case EVENT: + return tasks.add(new Event(Parser.getDescription(input), Parser.getDate(input))); + case MARK: + return tasks.mark(Parser.getIndex(input)); + case UNMARK: + return tasks.unmark(Parser.getIndex(input)); + case DELETE: + return tasks.delete(Parser.getIndex(input)); + case FIND: + return tasks.find(Parser.getDescription(input)); + case BYE: + return tasks.exit(); + case HELLO: + return tasks.greet(); + case NOTE: + return notes.add(Parser.getNote(Parser.getDescription(input))); + case CHECKNOTE: + return notes.checkNotes(); + case DELETENOTE: + return notes.delete(Parser.getDescription(input)); + case HELP: + return getHelpMessage(); + default: + return OUTPUT_ERROR_MSG; + } + } catch (DukeException e) { + return e.toString(); + } + + } + + public String getStartOutput() { + return START_MSG; + } + + public String getHelpMessage() { + return "BMO is happy to help! Here are a list of commands that BMO is able to interpret: \n" + + "todo, deadline, event, mark, unmark, delete, note, checknote, deletenote"; + /* + + "$ todo [description] -- adds a simple todo task\n" + + "$ deadline [description] /[yyyy-mm-dd] -- adds a deadline\n" + + "$ event [description] /[yyyy-mm-dd] -- adds an event\n" + + "$ mark [index] -- marks the task in your list\n" + + "$ unmark [index] -- unmarks the task in your list\n" + + "$ delete [index] -- deletes the task from your list\n" + + "$ note [label]: [description] -- adds a new note\n" + + "$ checknote -- check your notes\n" + + "$ deletenote [label] -- delete the note with that label"; + + */ + } +} diff --git a/src/main/resources/images/BMO.png b/src/main/resources/images/BMO.png new file mode 100644 index 0000000000..91eb3879fd Binary files /dev/null and b/src/main/resources/images/BMO.png differ diff --git a/src/main/resources/images/BMO2.png b/src/main/resources/images/BMO2.png new file mode 100644 index 0000000000..c1ad4672e6 Binary files /dev/null and b/src/main/resources/images/BMO2.png differ diff --git a/src/main/resources/images/DaDuke.png b/src/main/resources/images/DaDuke.png new file mode 100644 index 0000000000..d893658717 Binary files /dev/null and b/src/main/resources/images/DaDuke.png differ diff --git a/src/main/resources/images/UserPic.png b/src/main/resources/images/UserPic.png new file mode 100644 index 0000000000..ecb0fa1efc Binary files /dev/null and b/src/main/resources/images/UserPic.png differ diff --git a/src/main/resources/images/UserPic2.png b/src/main/resources/images/UserPic2.png new file mode 100644 index 0000000000..eca93e880e Binary files /dev/null and b/src/main/resources/images/UserPic2.png differ diff --git a/src/main/resources/images/UserPic3.jpg b/src/main/resources/images/UserPic3.jpg new file mode 100644 index 0000000000..dc25a5cb2d Binary files /dev/null and b/src/main/resources/images/UserPic3.jpg differ diff --git a/src/main/resources/images/UserPic3.png b/src/main/resources/images/UserPic3.png new file mode 100644 index 0000000000..36f7e98fa7 Binary files /dev/null and b/src/main/resources/images/UserPic3.png differ diff --git a/src/main/resources/images/png-clipart-computer-icons-user-account-graphics-account-icon-vector-icons-silhouette-thumbnail.png b/src/main/resources/images/png-clipart-computer-icons-user-account-graphics-account-icon-vector-icons-silhouette-thumbnail.png new file mode 100644 index 0000000000..bf3c90be00 Binary files /dev/null and b/src/main/resources/images/png-clipart-computer-icons-user-account-graphics-account-icon-vector-icons-silhouette-thumbnail.png differ diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml new file mode 100644 index 0000000000..98266fba4b --- /dev/null +++ b/src/main/resources/view/DialogBox.fxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml new file mode 100644 index 0000000000..f319d77b37 --- /dev/null +++ b/src/main/resources/view/MainWindow.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + +