diff --git a/README.md b/README.md deleted file mode 100644 index 90aa7f092a..0000000000 --- a/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Duke project template - -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. - -## Setting up in Intellij - -Prerequisites: JDK 17, 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 17** (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 - ____ _ - | _ \ _ _| | _____ - | | | | | | | |/ / _ \ - | |_| | |_| | < __/ - |____/ \__,_|_|\_\___| - ``` diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..44d651d305 --- /dev/null +++ b/build.gradle @@ -0,0 +1,59 @@ +plugins { + id 'java' + id 'application' + id 'com.github.johnrengelman.shadow' version '7.1.2' +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.10.0' + testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.0' + + String javaFxVersion = '17.0.7' + + 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' +} + +sourceCompatibility = '17' // Ensures the code is compatible with Java 17 (class file version 61) +targetCompatibility = '17' + +test { + useJUnitPlatform() + + testLogging { + events "passed", "skipped", "failed" + + showExceptions true + exceptionFormat "full" + showCauses true + showStackTraces true + showStandardStreams = false + } +} + +application { + mainClass.set("Launcher") +} + +shadowJar { + archiveBaseName = "duke" + archiveClassifier = null +} + +run{ + standardInput = System.in +} diff --git a/data.txt b/data.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/README.md b/docs/README.md index 47b9f984f7..a6c2235287 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,30 +1,125 @@ -# Duke User Guide +# Jeff User Guide -// Update the title above to match the actual product name +![](Ui.png) -// Product screenshot goes here - -// Product intro goes here +Jeff is your personal assistant for maintaining tasks and deadlines. ## Adding deadlines -// Describe the action and its outcome. +Usage: deadline (task description) /by (deadline) + +Example: `deadline Math Assignment /by 20th September 2024 5pm` + +Expected Outcome: The Task will be added to your list of tasks + + +Expected Output: +``` +Got it. I've added this task: +[D][] Math Assignment (by: 20th September 2024 5pm) +Now you have 1 task in the list. +``` + +## Adding todos -// Give examples of usage +Usage: todo (task description) -Example: `keyword (optional arguments)` +Example: `todo Math Assignment` -// A description of the expected outcome goes here +Expected Outcome: The Task is added to your list of tasks +Expected Output: ``` -expected output +Got it. I've added this task: +[T][] Math Assignment +Now you have 1 task in the list. ``` -## Feature ABC +## Adding Events + +Usage: Event (task description) /from (start time) /to (end time) + +Example: `event Math Exam /from (September 20th 2024 2pm) /to (September 20th 2024 4pm)` + +Expected Outcome: The Task is added to your list of tasks + +Expected Output: +``` +Got it. I've added this task: +[E][] Math Exam (from:(September 20th 2024 2pm) to:(September 20th 2024 4pm)) +Now you have 1 task in the list. +``` + +## Marking Events + +Usage: mark (task number) + +Example: `mark 1` + +Expected Outcome: Task 1 is marked + +Expected Output: +``` +Nice! I've marked this task as done: +[D][X] Math Assignment (by: 20th September 2024 5pm) +``` + +## Unmarking Events + +Usage: unmark (task number) -// Feature details +Example: `unmark 1` +Expected Outcome: Task 1 is marked + +Expected Output: +``` +OK, I've marked this task as not done yet: +[D][] Math Assignment (by: 20th September 2024 5pm) +``` + +## Listing Tasks + +Usage: list + +Example: `list` + +Expected Outcome: All lists along with their ranks are listed + +Expected Output: +``` +1.[D][] Math Assignment (by: 20th September 2024 5pm) +2.[E][] Math Exam (from:(September 20th 2024 2pm) to:(September 20th 2024 4pm)) +``` + +## Deleting Tasks +Usage: delete (task number) + +Example: `delete 1` + +Expected Outcome: the first task is deleted from the task list + +Expected Output: +``` +Noted. I've removed this task: +[D][] Math Assignment (by: 20th September 2024 5pm) +Now you have 1 task in the list. +``` + +## Finding Tasks +Usage: find (search query) + +Example: `find Math` + +Expected Outcome: All tasks containing the word "Math" (NOTE: This is case-sensitive) will be listed + +Expected Output: +``` +1.[T][] Math Assignment +2.[E][] Math Exam (from:(September 20th 2024 2pm) to:(September 20th 2024 4pm)) +``` -## Feature XYZ +## Exiting Chat +Usage: bye! -// Feature details \ No newline at end of file +Expected Outcome: The chat is terminated ( but all data is saved ) \ No newline at end of file diff --git a/docs/Ui.png b/docs/Ui.png new file mode 100644 index 0000000000..f31fae5451 Binary files /dev/null and b/docs/Ui.png differ diff --git a/duke.jar b/duke.jar new file mode 100644 index 0000000000..bf226af466 Binary files /dev/null and b/duke.jar differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..033e24c4cd 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..66c01cfeba --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..fcb6fca147 --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/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/HEAD/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 + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# 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 + if ! command -v java >/dev/null 2>&1 + then + 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 +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + 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 + + +# 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"' + +# 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 \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# 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..6689b85bee --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@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=. +@rem This is normally unused +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% equ 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% equ 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! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/releases/data.txt b/releases/data.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/releases/duke.jar b/releases/duke.jar new file mode 100644 index 0000000000..0645cbad47 Binary files /dev/null and b/releases/duke.jar differ diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java deleted file mode 100644 index 5d313334cc..0000000000 --- a/src/main/java/Duke.java +++ /dev/null @@ -1,10 +0,0 @@ -public class Duke { - public static void main(String[] args) { - String logo = " ____ _ \n" - + "| _ \\ _ _| | _____ \n" - + "| | | | | | | |/ / _ \\\n" - + "| |_| | |_| | < __/\n" - + "|____/ \\__,_|_|\\_\\___|\n"; - System.out.println("Hello from\n" + logo); - } -} diff --git a/src/main/java/duke/ArgumentNotFoundException.java b/src/main/java/duke/ArgumentNotFoundException.java new file mode 100644 index 0000000000..2bfb7da141 --- /dev/null +++ b/src/main/java/duke/ArgumentNotFoundException.java @@ -0,0 +1,14 @@ +package duke; + +public class ArgumentNotFoundException extends Exception { + public ArgumentNotFoundException(String message) { + super(message); + this.msg = message; + } + + public String getMsg() { + return this.msg; + } + + public String msg; +} diff --git a/src/main/java/duke/Deadline.java b/src/main/java/duke/Deadline.java new file mode 100644 index 0000000000..ca7787bf74 --- /dev/null +++ b/src/main/java/duke/Deadline.java @@ -0,0 +1,61 @@ +package duke; +import duke.Task; + +public class Deadline extends Task { + Deadline(String name, String deadline) { + super(name); + this.deadline = deadline; + } + + @Override + public void mark() { + this.isMarked = true; + } + + @Override + public void unmark() { + this.isMarked = false; + } + + @Override + public String print() { + String message = ""; + + message += "[D]"; + + if(this.isMarked) { + message += "[X] "; + } else { + message += "[ ] "; + } + + message += this.name; + + message += " (by: " + this.deadline + ")"; + + System.out.println(message); + return message; + } + + @Override + public String print(int rank) { + String message = rank + "."; + + message += "[D]"; + + if(this.isMarked) { + message += "[X] "; + } else { + message += "[ ] "; + } + + message += name; + + message += " (by: " + deadline + ")"; + + System.out.println(message); + return message; + } + + public String deadline; +} diff --git a/src/main/java/duke/DialogBox.java b/src/main/java/duke/DialogBox.java new file mode 100644 index 0000000000..301b48073e --- /dev/null +++ b/src/main/java/duke/DialogBox.java @@ -0,0 +1,61 @@ +import duke.Duke; + +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; + +/** + * Represents a dialog box consisting of an ImageView to represent the speaker's face + * and a label containing text from the speaker. + */ +public class DialogBox extends HBox { + @FXML + private Label dialog; + @FXML + private ImageView displayPicture; + + private DialogBox(String text, Image img) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml")); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + fxmlLoader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + dialog.setText(text); + displayPicture.setImage(img); + } + + /** + * Flips the dialog box such that the ImageView is on the left and text on the right. + */ + private void flip() { + ObservableList tmp = FXCollections.observableArrayList(this.getChildren()); + Collections.reverse(tmp); + getChildren().setAll(tmp); + setAlignment(Pos.TOP_LEFT); + } + + public static DialogBox getUserDialog(String text, Image img) { + return new DialogBox(text, img); + } + + public static DialogBox getDukeDialog(String text, Image img) { + var db = new DialogBox(text, img); + db.flip(); + return db; + } +} + diff --git a/src/main/java/duke/Duke$Parser.class b/src/main/java/duke/Duke$Parser.class new file mode 100644 index 0000000000..360da46d4a Binary files /dev/null and b/src/main/java/duke/Duke$Parser.class differ diff --git a/src/main/java/duke/Duke$Storage.class b/src/main/java/duke/Duke$Storage.class new file mode 100644 index 0000000000..2617e2f52d Binary files /dev/null and b/src/main/java/duke/Duke$Storage.class differ diff --git a/src/main/java/duke/Duke$Task.class b/src/main/java/duke/Duke$Task.class new file mode 100644 index 0000000000..e331279628 Binary files /dev/null and b/src/main/java/duke/Duke$Task.class differ diff --git a/src/main/java/duke/Duke$TaskList.class b/src/main/java/duke/Duke$TaskList.class new file mode 100644 index 0000000000..ef852a3176 Binary files /dev/null and b/src/main/java/duke/Duke$TaskList.class differ diff --git a/src/main/java/duke/Duke$Ui.class b/src/main/java/duke/Duke$Ui.class new file mode 100644 index 0000000000..3498a148c3 Binary files /dev/null and b/src/main/java/duke/Duke$Ui.class differ diff --git a/src/main/java/duke/Duke.class b/src/main/java/duke/Duke.class new file mode 100644 index 0000000000..0d95e1f594 Binary files /dev/null and b/src/main/java/duke/Duke.class differ diff --git a/src/main/java/duke/Duke.java b/src/main/java/duke/Duke.java new file mode 100644 index 0000000000..92f6880c27 --- /dev/null +++ b/src/main/java/duke/Duke.java @@ -0,0 +1,270 @@ +package duke; + +import java.util.Scanner; +import java.util.ArrayList; +import java.io.File; +import java.io.FileWriter; +import java.io.FileReader; +import java.io.BufferedReader; +import java.io.IOException; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + + +public class Duke { + + public static int TODO = 0; + public static int DEADLINE = 1; + public static int EVENT = 2; + + + public static boolean isEmptyString(String str) { + for(int i=0; i 5; + + if(input.length() == 4) { + ui.printError("Error: The description of a todo cannot be empty."); + response = "Error: The description of a todo cannot be empty."; + return response; + } + + String taskName = parser.getArgument('\n'); + + if(isEmptyString(taskName)) { + ui.printError("Error: The description of a todo cannot be empty."); + response = "Error: The description of a todo cannot be empty."; + return response; + } + + taskName = taskName.trim(); + + if(taskName.length() == 0) { + ui.printError("Error: The description of a todo cannot be empty."); + response = "Error: The description of a todo cannot be empty."; + return response; + } + + response = taskList.addTask(new Todo(taskName)); + } else if(command.equals("deadline")) { + assert input.length() > 9; + + + if(input.length() <= 9) { + ui.printError("Error: The description of a deadline cannot be empty."); + response = "Error: The description of a deadline cannot be empty."; + return response; + } + + String taskName = ""; + + try { + taskName = parser.getArgumentStr("/by ", 4); + } catch (ArgumentNotFoundException e) { + //System.out.println(e.getMessage()); + return e.getMsg(); + } + + if(isEmptyString(taskName)) { + ui.printError("Error: The description of a deadline cannot be empty."); + response = "Error: The description of a deadline cannot be empty."; + return response; + } + + if(input.length() <= 9 + taskName.length() + 4) { + ui.printError("Error: No deadline provided."); + response = "Error: No deadline provided."; + return response; + } + + String deadline = parser.getArgument('\n'); + deadline = deadline.trim(); + + if(isEmptyString(deadline)) { + ui.printError("Error: No deadline provided."); + response = "Error: No deadline provided."; + return response; + } + + taskName = taskName.trim(); + + if(isEmptyString(taskName)) { + ui.printError("Error: The description of a deadline cannot be empty."); + response = "Error: The description of a deadline cannot be empty."; + return response; + } + + response = taskList.addTask(new Deadline(taskName, deadline)); + + } else if(command.equals("event")) { + + assert input.length() > 6; + + if(input.length() <= 5) { + ui.printError("Error: The description of an event cannot be empty."); + response = "Error: The description of an event cannot be empty."; + return response; + } + + String taskName = ""; + + try { + taskName = parser.getArgumentStr("/from ", 6); + } catch (ArgumentNotFoundException e) { + return e.getMsg(); + } + + if(isEmptyString(taskName)) { + ui.printError("Error: The description of an event cannot be empty."); + response = "Error: The description of an event cannot be empty."; + return response; + } + + if(input.length() <= 6 + taskName.length() + 6) { + ui.printError("Error: No start time provided for event."); + response = "Error: No start time provided for event."; + return response; + } + + String startTime; + + try { + startTime = parser.getArgumentStr("/to ", 4); + } catch(ArgumentNotFoundException e) { + return e.getMsg(); + } + + if(isEmptyString(startTime)) { + ui.printError("Error: No start time provided for event."); + response = "Error: No start time provided for event."; + return response; + } + + if(input.length() <= 6 + taskName.length() + 6 + startTime.length() + 4) { + ui.printError("Error: No end time provided for event."); + response = "Error: No end time provided for event."; + return response; + } + + String endTime = parser.getArgument('\n'); + endTime = endTime.trim(); + + if(isEmptyString(endTime)) { + ui.printError("Error: No end time provided for event."); + response = "Error: No end time provided for event."; + return response; + } + + taskName = taskName.trim(); + startTime = startTime.trim(); + + if(isEmptyString(taskName)) { + ui.printError("Error: The description of an event cannot be empty."); + response = "Error: The description of an event cannot be empty."; + return response; + } + + String[] eventTimings = new String[] {startTime, endTime}; + + + response = taskList.addTask(new Event(taskName, eventTimings)); + } else if(command.equals("delete")) { + assert input.length() > 7; + + if(input.length() <= 7) { + ui.printError("Error: You need to specify which task to delete."); + response = "Error: You need to specify which task to delete."; + return response; + } + + int rankToDelete = Integer.valueOf(parser.getArgument('\n')); + + try { + response = taskList.deleteTask(rankToDelete); + } catch (TaskOutOfBounds e) { + return e.getMsg(); + } + + } else if(command.equals("find")) { + assert input.length() > 5; + + if(input.length() <= 5) { + ui.printError("Error: You need to give a search query."); + response = "Error: You need to give a search query."; + return response; + } + String query = parser.getArgument('\n'); + response = taskList.fetchQuery(query); + } else { + + System.out.println("Error: Invalid input."); + return "Error: Invalid input"; + } + + saver.save(taskList); + return response; + } + +} \ No newline at end of file diff --git a/src/main/java/duke/Event.java b/src/main/java/duke/Event.java new file mode 100644 index 0000000000..7a5317ae7d --- /dev/null +++ b/src/main/java/duke/Event.java @@ -0,0 +1,88 @@ +package duke; +import duke.Task; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class Event extends Task { + Event(String name, String[] eventTimings) { + super(name); + + // if user gives date in yyyy-mm-dd, then we format it to MMM dd yyyy + // otherwise we do nothing, as we accept other input types or formats + // for date. + + try { + LocalDate date = LocalDate.parse(eventTimings[0], DateTimeFormatter.ISO_DATE); + DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("MMM dd yyyy"); + + eventTimings[0] = date.format(myFormatObj); + } catch (Exception e) { + // do nothing + System.out.println(e); + } + + try { + LocalDate date = LocalDate.parse(eventTimings[1], DateTimeFormatter.ISO_DATE); + DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("MMM dd yyyy"); + + eventTimings[1] = date.format(myFormatObj); + } catch (Exception e) { + // do nothing + } + + this.eventTimings = eventTimings; + } + + @Override + public void mark() { + this.isMarked = true; + } + + @Override + public void unmark() { + this.isMarked = false; + } + + @Override + public String print() { + String message = ""; + + message += "[E]"; + + if(this.isMarked) { + message += "[X] "; + } else { + message += "[ ] "; + } + + message += this.name; + + message += " (from: " + this.eventTimings[0] + " to: " + this.eventTimings[1] + ")"; + + System.out.println(message); + return message; + } + + @Override + public String print(int rank) { + String message = rank + "."; + + message += "[E]"; + + if(this.isMarked) { + message += "[X] "; + } else { + message += "[ ] "; + } + + message += name; + + message += " (from: " + this.eventTimings[0] + " to: " + this.eventTimings[1] + ")"; + + System.out.println(message); + return message; + } + + public String[] eventTimings; +} diff --git a/src/main/java/duke/Launcher.java b/src/main/java/duke/Launcher.java new file mode 100644 index 0000000000..b2efccbad7 --- /dev/null +++ b/src/main/java/duke/Launcher.java @@ -0,0 +1,12 @@ +import duke.Duke; + +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/duke/Loader.java b/src/main/java/duke/Loader.java new file mode 100644 index 0000000000..3f9dbd798b --- /dev/null +++ b/src/main/java/duke/Loader.java @@ -0,0 +1,11 @@ +package duke; + +public class Loader extends Storage { + Loader(String filepath, Ui ui) { + super(filepath, ui); + } + + public TaskList load() { + return super.load(); + } +} diff --git a/src/main/java/duke/Main.java b/src/main/java/duke/Main.java new file mode 100644 index 0000000000..67b8f4105f --- /dev/null +++ b/src/main/java/duke/Main.java @@ -0,0 +1,31 @@ +import duke.Duke; + +import java.io.IOException; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.layout.AnchorPane; +import javafx.stage.Stage; + +/** + * A GUI for Duke using FXML. + */ +public class Main extends Application { + + private Duke duke = new Duke(); + + @Override + public void start(Stage stage) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml")); + AnchorPane ap = fxmlLoader.load(); + Scene scene = new Scene(ap); + stage.setScene(scene); + fxmlLoader.getController().setDuke(duke); // inject the Duke instance + stage.show(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/duke/MainWindow.java b/src/main/java/duke/MainWindow.java new file mode 100644 index 0000000000..2b8e1675b7 --- /dev/null +++ b/src/main/java/duke/MainWindow.java @@ -0,0 +1,55 @@ +import duke.Duke; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; +/** + * Controller for the main GUI. + */ +public class MainWindow extends AnchorPane { + @FXML + private ScrollPane scrollPane; + @FXML + private VBox dialogContainer; + @FXML + private TextField userInput; + @FXML + private Button sendButton; + + private Duke duke; + + private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.png")); + private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png")); + + @FXML + public void initialize() { + scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); + dialogContainer.getChildren().addAll( + DialogBox.getDukeDialog("Hello! I'm Jeff\n " + + "What can I help you with today?", dukeImage) + ); + } + + /** Injects the Duke instance */ + public void setDuke(Duke d) { + duke = d; + } + + /** + * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to + * the dialog container. Clears the user input after processing. + */ + @FXML + private void handleUserInput() { + String input = userInput.getText(); + String response = duke.getResponse(input); + dialogContainer.getChildren().addAll( + DialogBox.getUserDialog(input, userImage), + DialogBox.getDukeDialog(response, dukeImage) + ); + userInput.clear(); + } +} diff --git a/src/main/java/duke/Parser.java b/src/main/java/duke/Parser.java new file mode 100644 index 0000000000..2c8f90e714 --- /dev/null +++ b/src/main/java/duke/Parser.java @@ -0,0 +1,120 @@ +package duke; + +public class Parser { + + /** + * Returns a Parser object for parsing user commands + */ + public Parser() { + userInput = ""; + this.ptr = 0; + } + + /** + * Returns a Parser object for parsing user commands + * + * @param userInput the entire command the user has sent + * @return Parser object + */ + public Parser(String userInput) { + this.userInput = userInput; + this.ptr = 0; + } + + + /** + * Returns void, just resets the parser state to match new + * user command that was inputted + * + * @param newUserInput the new command the user has inputted + */ + public void readInput(String newUserInput) { + this.userInput = newUserInput; + this.ptr = 0; + } + + /** + * Returns a substring of this.userInput starting from ptr + * until the first instance of the escapeCharacter that + * appears past ptr. + * + * @param escapeCharacter the escape character that determines + * the end of the substring we should return + * @return the substring from ptr to escapeCharacter (exclusive) + */ + public String getArgument(char escapeCharacter) { + int len = userInput.length(); + int startIndex = ptr; + + while(ptr < len) { + if(userInput.charAt(ptr) == escapeCharacter) { + break; + } + ptr++; + } + + return userInput.substring(startIndex, ptr++); + } + + /** + * Returns a substring of this.userInput starting from ptr + * until the first instance of the escapeCharacter that + * appears past ptr, and then advances the ptr by advanceAmount + * + * @param escapeCharacter the escape character that determines + * the end of the substring we should return + * @return the substring from ptr to escapeCharacter (exclusive) + */ + public String getArgument(char escapeCharacter, int advanceAmount) { + int len = userInput.length(); + int startIndex = ptr; + + while(ptr < len) { + if(userInput.charAt(ptr) == escapeCharacter) { + break; + } + ptr++; + } + + int oldPtr = ptr; + ptr += advanceAmount; + + return userInput.substring(startIndex, oldPtr); + } + + /** + * Returns a substring of this.userInput starting from ptr + * until the first instance of the escapeString that + * appears past ptr, and then advances the ptr by advanceAmount + * + * @param escapeString the escape character that determines + * the end of the substring we should return + * @return the substring from ptr to escapeCharacter (exclusive) + */ + public String getArgumentStr(String escapeString, int advanceAmount) throws ArgumentNotFoundException { + int len = userInput.length(); + int escapeLen = escapeString.length(); + int startIndex = ptr; + + while(ptr < len) { + if(ptr + escapeLen < len && userInput.substring(ptr, ptr + escapeLen).equals(escapeString)) { + break; + } + ptr++; + } + + if(ptr >= len) { + String errMsg = escapeString + " argument not present!"; + ArgumentNotFoundException e = new ArgumentNotFoundException(errMsg); + throw e; + } + + int oldPtr = ptr; + ptr += advanceAmount; + + return userInput.substring(startIndex, oldPtr); + } + + String userInput; + int ptr; +} diff --git a/src/main/java/duke/Saver.java b/src/main/java/duke/Saver.java new file mode 100644 index 0000000000..ac57c5a63b --- /dev/null +++ b/src/main/java/duke/Saver.java @@ -0,0 +1,13 @@ +package duke; + +public class Saver extends Storage { + Saver(String filepath, Ui ui) { + super(filepath, ui); + } + + public void save(TaskList taskList) { + super.save(taskList); + } + + +} diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java new file mode 100644 index 0000000000..9526bde44e --- /dev/null +++ b/src/main/java/duke/Storage.java @@ -0,0 +1,178 @@ +package duke; + +import java.io.*; +import java.util.ArrayList; + +public class Storage { + + public static int TODO = 0; + public static int DEADLINE = 1; + public static int EVENT = 2; + + /** + * Returns a substring of message from [startIndex, z) where z is the index + * of the first escapeCharacter that occurs in message from startIndex onwards. + * + * @param message the entire message we want to analyze + * @param startIndex the starting index for our substring + * @param escapeCharacter the character that we wish to use as a terminating character + * @return the desired substring from startIndex up until the first escapeCharacter + */ + public static String getCommand(String message, int startIndex, char escapeCharacter) { + int len = message.length(); + int ptr = startIndex; + + while(ptr < len) { + if(message.charAt(ptr) == escapeCharacter) { + break; + } + ptr++; + } + + return message.substring(startIndex, ptr++); + } + + /** + * Returns a storage object for saving and loading Task Lists + * + * @param filepath the path to the storage file where we store + * the task list data + * @param ui a ui object for printing to terminal + */ + Storage(String filepath, Ui ui) { + this.filepath = filepath; + this.ui = ui; + } + + /** + * Returns void, saves a taskList to a storage file. + * The data format is TASK_TYPE|MARKED|TASK_NAME|DEADLINE1|DEADLINE2| + * + * @param taskList the task list that we wish to save + * to a storage file + */ + public void save(TaskList taskList) { + + ArrayList tasks = taskList.tasks; + try { + File myObj = new File(filepath); + myObj.createNewFile(); + + FileWriter fw = new FileWriter(filepath); + + int tasksLen = tasks.size(); + + for(int i=0; i(); + this.ui = ui; + } + + /** + * Returns a TaskList object + * + * @param tasks an array list of Task objects which we + * can directly copy into our tasks field + * @param ui a ui object for printing to the terminal when + * the TaskList object is modified + */ + TaskList(ArrayList tasks, Ui ui) { + this.tasks = tasks; + this.ui = ui; + } + + /** + * Returns a TaskList object + * + * @param taskList an existing taskList object that we can + * copy into this object + * @param ui a ui object for printing to the terminal when + * the TaskList object is modified + */ + TaskList(TaskList taskList, Ui ui) { + this.tasks = taskList.tasks; + this.ui = ui; + } + + /** + * Returns String, just adds task to our array of tasks + * + * @param task the task to add + */ + String addTask(Task task) { + tasks.add(task); + return ui.printTaskAdded(task, tasks.size()); + } + + void addTaskWithoutPrinting(Task task) { + tasks.add(task); + } + + /** + * Returns String, just deletes a task from our array of tasks + * + * @param rank the 1-indexed index of the task we wish to remove + */ + String deleteTask(int rank) throws TaskOutOfBounds { + assert rank >= 1; + assert rank <= tasks.size(); + + if(rank < 1 || rank > tasks.size()) { + throw new TaskOutOfBounds("Error: The task index number is out of bounds."); + } + + Task toRemove = tasks.get(rank-1); + tasks.remove(rank-1); + + return ui.printTaskDeleted(toRemove, tasks.size()); + } + + /** + * Returns String, prints all the tasks out to the terminal + */ + String listTasks() { + int numberOfMessages = tasks.size(); + String response = ""; + response += ui.horizontalLine; + ui.printHorizontalLine(); + + for(int i=0; i= 1; + assert rank <= tasks.size(); + + if(rank < 1 || rank > tasks.size()) { + throw new TaskOutOfBounds("Error: The task index number is out of bounds."); + } + Task task = tasks.get(rank - 1); + + task.mark(); + + return ui.printTaskMarked(task); + } + + /** + * Returns String, just unmarks a task in our array of tasks + * + * @param rank the 1-indexed index of the task we wish to unmark + * in our array of tasks + */ + String unmarkTask(int rank) throws TaskOutOfBounds { + assert rank >= 1; + assert rank <= tasks.size(); + + if(rank < 1 || rank > tasks.size()) { + throw new TaskOutOfBounds("Error: The task index number is out of bounds."); + } + + Task task = tasks.get(rank - 1); + + task.unmark(); + + return ui.printTaskUnmarked(task); + } + + private boolean isMatch(String query, Task task) { + String taskName = task.name; + int qlen = query.length(); + int tlen = taskName.length(); + + if(qlen > tlen) { + return false; + } + + int startPtr = 0; + int endPtr = qlen-1; + + while(endPtr < tlen) { + if(taskName.substring(startPtr, endPtr + 1).equals(query)) { + return true; + } + + ++startPtr; + ++endPtr; + } + + return false; + } + + /** + * Returns String, prints out all tasks that match the search query + * + * @param query the search query used to filter out tasks + */ + String fetchQuery(String query) { + String response = ""; + + int len = tasks.size(); + ArrayList matchingTasks = new ArrayList(); + + ui.printHorizontalLine(); + response += ui.horizontalLine + '\n'; + + System.out.println("Here are the matching tasks in your list:"); + response += "Here are the matching tasks in your list:\n"; + + for(int i=0; i tasks; + Ui ui; +} diff --git a/src/main/java/duke/TaskOutOfBounds.java b/src/main/java/duke/TaskOutOfBounds.java new file mode 100644 index 0000000000..32b889e3ff --- /dev/null +++ b/src/main/java/duke/TaskOutOfBounds.java @@ -0,0 +1,14 @@ +package duke; + +public class TaskOutOfBounds extends Exception { + public TaskOutOfBounds(String message) { + super(message); + this.msg = message; + } + + public String getMsg() { + return this.msg; + } + + public String msg; +} diff --git a/src/main/java/duke/Todo.java b/src/main/java/duke/Todo.java new file mode 100644 index 0000000000..9a6d1aa5d1 --- /dev/null +++ b/src/main/java/duke/Todo.java @@ -0,0 +1,54 @@ +package duke; +import duke.Task; + +public class Todo extends Task { + Todo(String name) { + super(name); + } + + @Override + public void mark() { + this.isMarked = true; + } + + @Override + public void unmark() { + this.isMarked = false; + } + + @Override + public String print() { + String message = ""; + + message += "[T]"; + + if(this.isMarked) { + message += "[X] "; + } else { + message += "[ ] "; + } + + message += this.name; + + System.out.println(message); + return message; + } + + @Override + public String print(int rank) { + String message = rank + "."; + + message += "[T]"; + + if(this.isMarked) { + message += "[X] "; + } else { + message += "[ ] "; + } + + message += name; + + System.out.println(message); + return message; + } +} diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java new file mode 100644 index 0000000000..36d1141936 --- /dev/null +++ b/src/main/java/duke/Ui.java @@ -0,0 +1,166 @@ +package duke; + +import duke.*; + +public class Ui { + + /** + * Returns a Ui object which is used to output + * to the terminal to communicate with user + * + * @param openingText the opening message sent to users. + * @param closingText the final message sent to users. + * @return Ui object + */ + Ui(String openingText, String closingText) { + this.openingText = openingText; + this.closingText = closingText; + this.horizontalLine = horizontalLine = "----------------------------------------------------------"; + } + + /** + * Returns void, just prints a horizontal line + */ + void printHorizontalLine() { + System.out.println(horizontalLine); + } + + /** + * Returns void, just prints the opening text + */ + void printOpening() { + System.out.println(horizontalLine); + System.out.println(openingText); + System.out.println(horizontalLine); + } + /** + * Returns void, just prints a message + * + * @param message message to be printed. + */ + void printMessage(String message) { + System.out.println(horizontalLine); + System.out.println(message); + System.out.println(horizontalLine); + } + + /** + * Returns void, just prints the closing tex + */ + void printClosing() { + System.out.println(horizontalLine); + System.out.println(closingText); + System.out.println(horizontalLine); + } + + /** + * Returns void, just prints the latest task added + * + * @param task the task that was added + * @param len the length of the task list after adding the task + */ + String printTaskAdded(Task task, int len) { + String response = ""; + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + System.out.println("Got it. I've added this task:"); + response += "Got it. I've added this task:" + '\n'; + + task.print(); + response += task.print() + '\n'; + + System.out.println("Now you have " + len + " tasks in the list."); + response += "Now you have " + len + " tasks in the list." + '\n'; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + return response; + } + + /** + * Returns void, just prints the latest task deleted + * + * @param task the task that was added + * @param len the length of the task list after deleting the task + */ + String printTaskDeleted(Task task, int len) { + String response = ""; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + System.out.println("Noted. I've removed this task:"); + response += "Noted. I've removed this task:" + '\n'; + + response += task.print() + '\n'; + + System.out.println("Now you have " + len + " tasks in the list."); + response += "Now you have " + len + " tasks in the list." + '\n'; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + return response; + } + + /** + * Returns void, just prints the latest task marked + * + * @param task the task that was marked + */ + String printTaskMarked(Task task) { + String response = ""; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + System.out.println("Nice! I've marked this task as done:"); + response += "Nice! I've marked this task as done:" + '\n'; + + response += task.print() + '\n'; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + return response; + } + + /** + * Returns void, just prints the latest task unmarked + * + * @param task the task that was unmarked + */ + String printTaskUnmarked(Task task) { + String response = ""; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + System.out.println("OK, I've marked this task as not done yet:"); + response += "\"OK, I've marked this task as not done yet:" + '\n'; + + response += task.print() + '\n'; + + System.out.println(horizontalLine); + response += horizontalLine + '\n'; + + return response; + } + + /** + * Returns void, just prints error messages + * + * @param str the error message to print + */ + void printError(String str) { + System.out.println(horizontalLine); + System.out.println(str); + System.out.println(horizontalLine); + } + + String openingText; + String closingText; + String horizontalLine; +} diff --git a/src/main/resources/images/DaDuke.png b/src/main/resources/images/DaDuke.png new file mode 100644 index 0000000000..d893658717 Binary files /dev/null and b/src/main/resources/images/DaDuke.png differ diff --git a/src/main/resources/images/DaUser.png b/src/main/resources/images/DaUser.png new file mode 100644 index 0000000000..3c82f45461 Binary files /dev/null and b/src/main/resources/images/DaUser.png differ diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml new file mode 100644 index 0000000000..fe672c90ea --- /dev/null +++ b/src/main/resources/view/DialogBox.fxml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml new file mode 100644 index 0000000000..c8a49611bb --- /dev/null +++ b/src/main/resources/view/MainWindow.fxml @@ -0,0 +1,44 @@ + + + + + + + + + + + +