diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..41c9256d24 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Frenchie.Frenchie + diff --git a/README.md b/README.md index 8715d4d915..a8c12bc91b 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,151 @@ -# 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 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 - ____ _ - | _ \ _ _| | _____ - | | | | | | | |/ / _ \ - | |_| | |_| | < __/ - |____/ \__,_|_|\_\___| - ``` +# Frenchie User Guide + +## Features + +### Feature 1 - Storing tasks + +Storing of 3 different tasks: +1. To Do (with no deadline) +2. Deadlines (with a deadline) +3. Events (with a Start and End time) + +### Feature 2 - Listing of stored tasks +### Feature 3 - Marking tasks as done/undone +### Feature 4 - Deleting tasks from the list +### Feature 5 - Searching for all tasks containing any keyword + +## Usage + +### `todo` - Adds a ToDo type task into the list + + + +Example of usage: + +`todo read book` + +Expected outcome: + +Frenchie will return this message for successfully adding a task to the list. [T] represents a ToDo task and the [ ] indicates the task is not yet completed. + ``` +Got it! I've added this task: + +[T][ ] read book + +Now you have X tasks in the list. +``` + +### `deadline` - Adds a Deadline type task into the list. + +Deadline has to be in format dd/MM/yyyy HH:mm. + +Example of usage: + +`deadline read book /by 09/09/2023 18:00` + +Expected outcome: + +Frenchie will return this message for successfully adding a task to the list. [D] represents a Deadline task and the [ ] indicates the task is not yet completed. + ``` +Got it! I've added this task: + +[D][ ] read book (by: 2023-09-09 18:00). + +Now you have X tasks in the list. +``` + +### `event` - Adds an event type task into the list + +Start and end time of event have to be in format dd/MM/yyyy HH:mm. +Example of usage: + +`todo read book /from 09/09/2023 18:00 /to 09/09/2023 19:00` + +Expected outcome: + +Frenchie will return this message for successfully adding a task to the list. [E] represents an event task and the [ ] indicates the task is not yet completed. + ``` +Got it! I've added this task: + +[E][ ] read book (from: 2023-09-09 18:00 to: 2023-09-09 19:00) + +Now you have X tasks in the list. +``` + +### `list` - lists all tasks currently stored in Frenchie + +Example of usage: + +`list` + +Expected outcome: + +``` +1. [T][ ] read book +2. [D][ ] read book (by: 2023-09-09 18:00) +3. [E][ ] read book (from: 2023-09-09 18:00 to: 2023-09-09 19:00) +``` + +### `mark` - mark the specified task as complete + +Example of usage: + +`mark 1` + +Expected outcome: + +``` +Nice! I've marked this task as done: +[T][X] read book +``` + +### `unmark` - mark the specified task as complete + +Example of usage: + +`unmark 1` + +Expected outcome: + +``` +OK, I've marked this task as not done yet: +[T][ ] read book +``` + +### `delete` - delete the specified task from the list + +Example of usage: + +`delete 1` + +Expected outcome: + +``` +Noted. I've removed this task: +[T][ ] read book +Now you have X tasks in the list. +``` + +### `find` - search through the list and returns all tasks that contain the keyword + +Example of usage: + +`find book` + +Expected outcome: + +``` +Here are the matching tasks in your list: +1. [D][ ] read book (by: 2023-09-09 18:00) +2. [E][ ] read book (from: 2023-09-09 18:00 to: 2023-09-09 19:00) +``` + +### `help` - returns a quickstart guide for users who have forgotten any command + +Example of usage: + +`help` + +Expected outcome: + +A quickstart guide for Frenchie listing the commands. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..d89cf8ab92 --- /dev/null +++ b/build.gradle @@ -0,0 +1,62 @@ +plugins { + id 'java' + id 'application' + id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'checkstyle' +} +checkstyle { + toolVersion = '10.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' + +} + +test { + useJUnitPlatform() + + testLogging { + events "passed", "skipped", "failed" + + showExceptions true + exceptionFormat "full" + showCauses true + showStackTraces true + showStandardStreams = false + } +} + +application { + mainClass.set("Frenchie.Launcher") +} + +shadowJar { + archiveBaseName = "Frenchie" + archiveClassifier = null + archiveFileName = "Frenchie.jar" + dependsOn("distZip", "distTar") +} + +run{ + standardInput = System.in + enableAssertions = true +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..eb761a9b9a --- /dev/null +++ b/config/checkstyle/checkstyle.xml @@ -0,0 +1,434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml new file mode 100644 index 0000000000..39efb6e4ac --- /dev/null +++ b/config/checkstyle/suppressions.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/docs/README.md b/docs/README.md index 8077118ebe..a8c12bc91b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,151 @@ -# User Guide +# Frenchie User Guide ## Features -### Feature-ABC +### Feature 1 - Storing tasks -Description of the feature. +Storing of 3 different tasks: +1. To Do (with no deadline) +2. Deadlines (with a deadline) +3. Events (with a Start and End time) -### Feature-XYZ - -Description of the feature. +### Feature 2 - Listing of stored tasks +### Feature 3 - Marking tasks as done/undone +### Feature 4 - Deleting tasks from the list +### Feature 5 - Searching for all tasks containing any keyword ## Usage -### `Keyword` - Describe action +### `todo` - Adds a ToDo type task into the list + -Describe the action and its outcome. Example of usage: -`keyword (optional arguments)` +`todo read book` + +Expected outcome: + +Frenchie will return this message for successfully adding a task to the list. [T] represents a ToDo task and the [ ] indicates the task is not yet completed. + ``` +Got it! I've added this task: + +[T][ ] read book + +Now you have X tasks in the list. +``` + +### `deadline` - Adds a Deadline type task into the list. + +Deadline has to be in format dd/MM/yyyy HH:mm. + +Example of usage: + +`deadline read book /by 09/09/2023 18:00` + +Expected outcome: + +Frenchie will return this message for successfully adding a task to the list. [D] represents a Deadline task and the [ ] indicates the task is not yet completed. + ``` +Got it! I've added this task: + +[D][ ] read book (by: 2023-09-09 18:00). + +Now you have X tasks in the list. +``` + +### `event` - Adds an event type task into the list + +Start and end time of event have to be in format dd/MM/yyyy HH:mm. +Example of usage: + +`todo read book /from 09/09/2023 18:00 /to 09/09/2023 19:00` Expected outcome: -Description of the outcome. +Frenchie will return this message for successfully adding a task to the list. [E] represents an event task and the [ ] indicates the task is not yet completed. + ``` +Got it! I've added this task: + +[E][ ] read book (from: 2023-09-09 18:00 to: 2023-09-09 19:00) +Now you have X tasks in the list. ``` -expected output + +### `list` - lists all tasks currently stored in Frenchie + +Example of usage: + +`list` + +Expected outcome: + ``` +1. [T][ ] read book +2. [D][ ] read book (by: 2023-09-09 18:00) +3. [E][ ] read book (from: 2023-09-09 18:00 to: 2023-09-09 19:00) +``` + +### `mark` - mark the specified task as complete + +Example of usage: + +`mark 1` + +Expected outcome: + +``` +Nice! I've marked this task as done: +[T][X] read book +``` + +### `unmark` - mark the specified task as complete + +Example of usage: + +`unmark 1` + +Expected outcome: + +``` +OK, I've marked this task as not done yet: +[T][ ] read book +``` + +### `delete` - delete the specified task from the list + +Example of usage: + +`delete 1` + +Expected outcome: + +``` +Noted. I've removed this task: +[T][ ] read book +Now you have X tasks in the list. +``` + +### `find` - search through the list and returns all tasks that contain the keyword + +Example of usage: + +`find book` + +Expected outcome: + +``` +Here are the matching tasks in your list: +1. [D][ ] read book (by: 2023-09-09 18:00) +2. [E][ ] read book (from: 2023-09-09 18:00 to: 2023-09-09 19:00) +``` + +### `help` - returns a quickstart guide for users who have forgotten any command + +Example of usage: + +`help` + +Expected outcome: + +A quickstart guide for Frenchie listing the commands. \ No newline at end of file diff --git a/docs/Ui.png b/docs/Ui.png new file mode 100644 index 0000000000..131950ecc5 Binary files /dev/null and b/docs/Ui.png differ diff --git a/frenchie.txt b/frenchie.txt new file mode 100644 index 0000000000..2e61e845be --- /dev/null +++ b/frenchie.txt @@ -0,0 +1,5 @@ +[T][ ] a +[T][ ] mom +[T][ ] dad +[T][ ] uncle +[T][X] auntie 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/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/Frenchie/Command.java b/src/main/java/Frenchie/Command.java new file mode 100644 index 0000000000..7d9574a154 --- /dev/null +++ b/src/main/java/Frenchie/Command.java @@ -0,0 +1,16 @@ +package Frenchie; + +public enum Command { + list, + mark, + unmark, + delete, + todo, + deadline, + event, + invalid, + find, + help, + bye + +} diff --git a/src/main/java/Frenchie/Deadline.java b/src/main/java/Frenchie/Deadline.java new file mode 100644 index 0000000000..569fe20594 --- /dev/null +++ b/src/main/java/Frenchie/Deadline.java @@ -0,0 +1,42 @@ +package Frenchie; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +/** + * Represents a Deadline that is stored in the Task list of the Frenchie chatbot. + *

+ * The ToDo class inherits the 2 attributes from the Task class with an additional + * LocalDateTime attribute deadline. The deadline attribute represents the deadline + * by which the Deadline task has to be completed. + *

+ */ +public class Deadline extends Task { + LocalDateTime deadline; + + /** + * Constructs a new Deadline object, with a default false + * value for isCompleted as tasks inputted into the task list are incomplete. + * Takes in a String name which is the name of the task as + * well as a String deadline in the format "dd/MM/yyyy HH:mm". + */ + public Deadline(String name, String deadline) { + super(name); + this.isCompleted = false; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); + this.deadline = LocalDateTime.parse(deadline, formatter); + } + + /** + * Overrides the toString() method inherited from the Task class. + * [D] to indicate that the task is a deadline. + * Deadline is formatted in 'yyyy-MM-dd HH:mm' to output. + */ + @Override + public String toString() { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + String desiredFormat = this.deadline.format(formatter); + return "[D]" + super.toString() + "(by: " + desiredFormat + ")"; + } +} + + diff --git a/src/main/java/Frenchie/DialogBox.java b/src/main/java/Frenchie/DialogBox.java new file mode 100644 index 0000000000..d2c33813c2 --- /dev/null +++ b/src/main/java/Frenchie/DialogBox.java @@ -0,0 +1,63 @@ +package Frenchie; + +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; + +/** + * An example of a custom control using FXML. + * This control represents a dialog box consisting of an ImageView to represent the speaker's face and a label + * containing text from the speaker. + */ +public class DialogBox extends HBox { + @FXML + private Label dialog; + @FXML + private ImageView displayPicture; + + private DialogBox(String text, Image img) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml")); + fxmlLoader.setController(this); + fxmlLoader.setRoot(this); + fxmlLoader.load(); + } catch (IOException e) { + e.printStackTrace(); + } + + 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 getFrenchieDialog(String text, Image img) { + var db = new DialogBox(text, img); + db.flip(); + return db; + } +} + + diff --git a/src/main/java/Frenchie/Event.java b/src/main/java/Frenchie/Event.java new file mode 100644 index 0000000000..7fb0df978e --- /dev/null +++ b/src/main/java/Frenchie/Event.java @@ -0,0 +1,44 @@ +package Frenchie; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Represents an Event that inherits from the Task class. + *

+ * The Event class has 2 additional LocalDateTime attributes startTime and endTime + * which represent the time the event starts and ends respectively. + *

+ */ +public class Event extends Task { + LocalDateTime startTime; + LocalDateTime endTime; + + /** + * Constructs a new Event object, with a default false value for isCompleted + * as all tasks inputted into the task list are incomplete. + * Takes in a String which is the name of the task. + * Takes in String startTime and String endTime in the format "dd/MM/yyyy HH:mm" + * which is then parsed into a formatter and stored as LocalDateTime objects. + */ + public Event(String name, String startTime, String endTime) { + this.taskName = name; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); + this.startTime = LocalDateTime.parse(startTime, formatter); + this.endTime = LocalDateTime.parse(endTime, formatter); + this.isCompleted = false; + } + + /** + * Overrides the toString() method inherited from the Task class. + * [E] to indicate that the task is an Event. + * startTime and endTime is formatted in 'yyyy-MM-dd HH:mm' to output. + */ + @Override + public String toString() { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + String desiredStartFormat = this.startTime.format(formatter); + String desiredEndFormat = this.endTime.format(formatter); + return "[E]" + super.toString() + "(from: " + desiredStartFormat + " to: " + desiredEndFormat + ")"; + } +} diff --git a/src/main/java/Frenchie/Frenchie.java b/src/main/java/Frenchie/Frenchie.java new file mode 100644 index 0000000000..5da5ca4b26 --- /dev/null +++ b/src/main/java/Frenchie/Frenchie.java @@ -0,0 +1,189 @@ +package Frenchie; + + +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.application.Application; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Region; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import javafx.util.Duration; + + +public class Frenchie extends Application { + private TaskList tasks; + private Storage storage; + private Ui ui; + private ScrollPane scrollPane; + private VBox dialogContainer; + private TextField userInput; + private Button sendButton; + private Scene scene; + + public Frenchie() { + this.storage = new Storage("frenchie.txt"); + this.ui = new Ui(); + this.tasks = new TaskList(); + } + public Frenchie(String filepath) { + this.storage = new Storage(filepath); + this.ui = new Ui(); + try { + this.tasks = storage.load(); + } catch (FrenchieException e) { + tasks = new TaskList(); + } + } + public void start(Stage stage) { + //Step 1. Setting up required components + + //The container for the content of the chat to scroll. + scrollPane = new ScrollPane(); + dialogContainer = new VBox(); + scrollPane.setContent(dialogContainer); + + userInput = new TextField(); + sendButton = new Button("Send"); + + AnchorPane mainLayout = new AnchorPane(); + mainLayout.getChildren().addAll(scrollPane, userInput, sendButton); + + scene = new Scene(mainLayout); + stage.setScene(scene); + stage.show(); + + //Step 2. Formatting the window to look as expected + stage.setTitle("Frenchie"); + stage.setResizable(false); + stage.setMinHeight(600.0); + stage.setMinWidth(400.0); + + mainLayout.setPrefSize(400.0, 600.0); + + scrollPane.setPrefSize(385, 535); + scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); + scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); + + scrollPane.setVvalue(1.0); + scrollPane.setFitToWidth(true); + + // You will need to import `javafx.scene.layout.Region` for this. + dialogContainer.setPrefHeight(Region.USE_COMPUTED_SIZE); + userInput.setPrefWidth(325.0); + sendButton.setPrefWidth(55.0); + + AnchorPane.setTopAnchor(scrollPane, 1.0); + AnchorPane.setBottomAnchor(sendButton, 1.0); + AnchorPane.setRightAnchor(sendButton, 1.0); + AnchorPane.setLeftAnchor(userInput , 1.0); + AnchorPane.setBottomAnchor(userInput, 1.0); + + //Step 3. Add functionality to handle user input. + sendButton.setOnMouseClicked((event) -> { + //handleUserInput(); + }); + userInput.setOnAction((event) -> { + //handleUserInput(); + }); + //Scroll down to the end every time dialogContainer's height changes. + dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0)); + } + + + public String getResponse(String input) { + StringBuilder output = new StringBuilder(); + try { + tasks = storage.load(); + } catch (FrenchieException e) { + // Handle the exception if loading fails, e.g., display an error message + output.append("Error loading tasks from storage.\n"); + } + Command command = Parser.parseCommand(input); + String details = Parser.parseDetails(input); + + switch (command) { + case bye: + storage.save(tasks); + ui.closeScanner(); + output.append(this.exit()); + Timeline exitDelay = new Timeline(new KeyFrame(Duration.seconds(2), event -> Platform.exit())); + exitDelay.setCycleCount(1); + exitDelay.play(); + break; + case list: + output.append(this.listTasks()); + return output.toString(); + case mark: + int index = Integer.parseInt(details) - 1; + tasks.markTaskAsCompleted(index); + output.append(ui.markTaskAsComplete(tasks.get(index))); + storage.save(tasks); + return output.toString(); + case unmark: + index = Integer.parseInt(details) - 1; + tasks.markTaskAsIncomplete(index); + output.append(ui.markTaskAsIncompelte(tasks.get(index))); + storage.save(tasks); + return output.toString(); + case delete: + index = Integer.parseInt(details) - 1; + Task task = tasks.get(index); + tasks.deleteTask(index); + output.append(ui.deleteTask(task, tasks)); + storage.save(tasks); + return output.toString(); + case todo: + String taskName = details; + ToDo todo = new ToDo(taskName); + tasks.addTask(todo); + output.append(ui.addTask(todo, tasks)); + storage.save(tasks); + return output.toString(); + case deadline: + taskName = details.split("/by")[0].trim(); + String deadlineDate = details.split("/by")[1].trim(); + Deadline deadline = new Deadline(taskName, deadlineDate); + tasks.addTask(deadline); + output.append(ui.addTask(deadline, tasks)); + storage.save(tasks); + return output.toString(); + case event: + taskName = details.split("/")[0].trim(); + String startTime = details.split("/from")[1].split("/to")[0].trim(); + String endTime = input.split("/from")[1].split("/to")[1].trim(); + Event event = new Event(taskName, startTime, endTime); + tasks.addTask(event); + output.append(ui.addTask(event, tasks)); + storage.save(tasks); + return output.toString(); + case find: + String keyword = details; + output.append(ui.findMessage()); + output.append(tasks.returnMatchTasks(keyword)); + return output.toString(); + case help: + output.append(ui.helpMessage()); + return output.toString(); + default: + return "OOPS!!! That is an invalid command!\n " + + "NOTE: Dates have to be entered in the dd/MM/yyyy HH:mm format!"; + } + return output.toString(); + } + + public String exit() { + return ui.exitMessage(); + } + + public String listTasks() { + return ui.listTasks(tasks); + } + +} diff --git a/src/main/java/Frenchie/FrenchieException.java b/src/main/java/Frenchie/FrenchieException.java new file mode 100644 index 0000000000..ce960f3931 --- /dev/null +++ b/src/main/java/Frenchie/FrenchieException.java @@ -0,0 +1,7 @@ +package Frenchie; + +public class FrenchieException extends Exception { + public FrenchieException(String message) { + super(message); + } +} diff --git a/src/main/java/Frenchie/Launcher.java b/src/main/java/Frenchie/Launcher.java new file mode 100644 index 0000000000..86753f9962 --- /dev/null +++ b/src/main/java/Frenchie/Launcher.java @@ -0,0 +1,12 @@ +package Frenchie; + +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/Frenchie/Main.java b/src/main/java/Frenchie/Main.java new file mode 100644 index 0000000000..65c4f65100 --- /dev/null +++ b/src/main/java/Frenchie/Main.java @@ -0,0 +1,32 @@ +package Frenchie; + +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 Frenchie frenchie = new Frenchie(); + + @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().setFrenchie(frenchie); + stage.show(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} + diff --git a/src/main/java/Frenchie/MainWindow.java b/src/main/java/Frenchie/MainWindow.java new file mode 100644 index 0000000000..97e613621d --- /dev/null +++ b/src/main/java/Frenchie/MainWindow.java @@ -0,0 +1,55 @@ +package Frenchie; + +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 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 Frenchie frenchie; + + private Image userImage = new Image(this.getClass().getResourceAsStream("/images/FrenchieUser.jpg")); + private Image frenchieImage = new Image(this.getClass().getResourceAsStream("/images/FrenchieBot.jpeg")); + + @FXML + public void initialize() { + scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); + } + + public void setFrenchie(Frenchie frenchie) { + + this.frenchie = frenchie; + String openingMessage = " Hello! I'm Frenchie.\n" + + " What can I do for you?\n"; + dialogContainer.getChildren().addAll(DialogBox.getFrenchieDialog(openingMessage, frenchieImage)); + } + + /** + * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to + * the dialog container. Clears the user input after processing. + */ + @FXML + private void handleUserInput() throws FrenchieException { + String input = userInput.getText(); + String response = frenchie.getResponse(input); + dialogContainer.getChildren().addAll( + DialogBox.getUserDialog(input, userImage), + DialogBox.getFrenchieDialog(response, frenchieImage) + ); + userInput.clear(); + } +} diff --git a/src/main/java/Frenchie/Parser.java b/src/main/java/Frenchie/Parser.java new file mode 100644 index 0000000000..c15a152acc --- /dev/null +++ b/src/main/java/Frenchie/Parser.java @@ -0,0 +1,57 @@ +package Frenchie; + +/** + * This is a Parser object responsible for handling user input. + *

+ * This parser object interprets the user input based on the Command enums. + *

+ */ +public class Parser { + /** + * This method takes in the user's input to the chatbot and splits it to return the Command. + * @param input user input to the Frenchie Chatbot + * @return respective Command from the input string + */ + public static Command parseCommand(String input) { + + String[] parts = input.split(" "); + String command = parts[0]; + + switch (command) { + case "list": + return Command.list; + case "mark": + return Command.mark; + case "unmark": + return Command.unmark; + case "todo": + return Command.todo; + case "deadline": + return Command.deadline; + case "event": + return Command.event; + case "bye": + return Command.bye; + case "delete": + return Command.delete; + case "find": + return Command.find; + case "help": + return Command.help; + default: + return Command.invalid; + } + } + + /** + * This method takes in the user's input to the chatbot and splits it to obtain the details + * of the task: Task Name, Deadline, StartTime and EndTime if applicable. + * + * @param input user input to the Frenchie Chatbot. + * @return String containing all details of the task. + */ + public static String parseDetails(String input) { + String[] parts = input.split(" ", 2); + return (parts.length > 1) ? parts[1] : ""; + } +} diff --git a/src/main/java/Frenchie/Storage.java b/src/main/java/Frenchie/Storage.java new file mode 100644 index 0000000000..b1e9c76fd8 --- /dev/null +++ b/src/main/java/Frenchie/Storage.java @@ -0,0 +1,76 @@ +package Frenchie; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + + +public class Storage { + private String filePath; + + public Storage() { this.filePath = ""; } + public Storage(String filePath) { + this.filePath = filePath; + } + public TaskList load() throws FrenchieException { + TaskList loadedTasks = new TaskList(); + try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { + String input; + while ((input = reader.readLine()) != null) { + String taskType = Character.toString(input.charAt(1)); + String taskStatus = Character.toString(input.charAt(4)); + String taskDetails = input.substring(7); + if (taskType.equals("T")) { + ToDo currentTask = new ToDo(taskDetails); + if (taskStatus.equals("X")) { + currentTask.setIsCompleted(); + } + loadedTasks.addTask(currentTask); + } else if (taskType.equals("D")) { + String taskName = taskDetails.split("\\(")[0].trim(); + String deadline = taskDetails.split("\\(by: ")[1].split("\\)")[0]; + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + LocalDateTime storedDeadline = LocalDateTime.parse(deadline, inputFormatter); + DateTimeFormatter desiredFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); + String constructorDeadline = storedDeadline.format(desiredFormatter); + Deadline currentTask = new Deadline(taskName, constructorDeadline); + if (taskStatus.equals("X")) { + currentTask.setIsCompleted(); + } + loadedTasks.addTask(currentTask); + } else if (taskType.equals("E")) { + String taskName = taskDetails.split("\\(")[0].trim(); + String startTime = taskDetails.split("\\(")[1].split("from: ")[1].split(" to")[0]; + String endTime = taskDetails.split("\\(")[1].split("to: ")[1].split("\\)")[0]; + DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); + LocalDateTime storedStartTime = LocalDateTime.parse(startTime, inputFormatter); + LocalDateTime storedEndTime = LocalDateTime.parse(endTime, inputFormatter); + DateTimeFormatter desiredFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm"); + String constructorStartTime = storedStartTime.format(desiredFormatter); + String constructorEndTime = storedEndTime.format(desiredFormatter); + Event currentTask = new Event(taskName, constructorStartTime, constructorEndTime); + if (taskStatus.equals("X")) { + currentTask.setIsCompleted(); + } + loadedTasks.addTask(currentTask); + } + } + } catch (IOException e) { + throw new FrenchieException("Error loading tasks"); + } + return loadedTasks; + } + + public void save(TaskList taskList) { + try (PrintWriter writer = new PrintWriter("frenchie.txt")) { + for (Task task : taskList.tasks) { + writer.println(task.toString()); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/Frenchie/Task.java b/src/main/java/Frenchie/Task.java new file mode 100644 index 0000000000..2d84cfa027 --- /dev/null +++ b/src/main/java/Frenchie/Task.java @@ -0,0 +1,58 @@ +package Frenchie; + +/** + * Represents a Task that is stored in the Task list of the Frenchie chatbot. + *

+ * The task class has 2 attributes, isCompleted and taskName. + * isCompleted is a boolean attribute, returning true if the task has been completed + * and false if the task is incomplete. + * taskName is a String that stores the name of the task, such as 'Read Book'. + *

+ */ +public class Task { + public boolean isCompleted; + public String taskName; + + + public Task() { + isCompleted = false; + } + /** + * Constructs a new Task object, with a default false value for + * isCompleted as tasks inputted into the task list are incomplete. + * Takes in a String which is the name of the task. + */ + public Task(String name) { + this.taskName = name; + isCompleted = false; + } + + /** + * Marks Task as complete by setting the isCompleted attribute to true. + */ + public void setIsCompleted() { + isCompleted = true; + } + + /** + * Marks Task as incomplete by setting the isCompleted attribute to false. + */ + public void setIsIncomplete() { + isCompleted = false; + } + + /** + * Returns the isCompleted attribute to check if Task is completed. + */ + public boolean checkCompletion() { + return isCompleted; + } + @Override + public String toString() { + String indicator = " "; + if (isCompleted) { + indicator = "X"; + } + return "[" + indicator + "] " + taskName; + } +} diff --git a/src/main/java/Frenchie/TaskList.java b/src/main/java/Frenchie/TaskList.java new file mode 100644 index 0000000000..0592f247e8 --- /dev/null +++ b/src/main/java/Frenchie/TaskList.java @@ -0,0 +1,55 @@ +package Frenchie; + +import java.util.ArrayList; + +public class TaskList { + public ArrayList tasks; + + public TaskList() { + this.tasks = new ArrayList(); + } + + public String listTasks() { + int counter = 1; + StringBuilder output = new StringBuilder(); + for (Task task : tasks) { + output.append(counter).append(". ").append(task.toString()).append("\n"); + counter += 1; + } + return output.toString(); + } + + public Task get(int index) { + return this.tasks.get(index); + } + public void addTask(Task task) { + this.tasks.add(task); + } + + public int size() { + return this.tasks.size(); + } + public void deleteTask(int index) { + this.tasks.remove(index); + } + + public void markTaskAsCompleted(int index) { + this.tasks.get(index).setIsCompleted(); + } + + public String returnMatchTasks(String keyword) { + int counter = 1; + StringBuilder output = new StringBuilder(); + for (Task task: tasks) { + if (task.toString().contains(keyword)) { + output.append(counter).append(". ").append(task.toString()).append("\n"); + counter += 1; + } + } return output.toString(); + } + public void markTaskAsIncomplete(int index) { + this.tasks.get(index).setIsIncomplete(); + } + // Other methods for updating tasks +} + diff --git a/src/main/java/Frenchie/ToDo.java b/src/main/java/Frenchie/ToDo.java new file mode 100644 index 0000000000..ced615bf22 --- /dev/null +++ b/src/main/java/Frenchie/ToDo.java @@ -0,0 +1,25 @@ +package Frenchie; + +/** + * Represents a ToDo that inherits from the Task superclass. + *

+ * The ToDo class is indicated with a [T] in its toString() method. + *

+ */ +public class ToDo extends Task { + + /** + * Constructs a new ToDo object, with a default false value for isCompleted + * as tasks inputted into the task list are incomplete. + * Takes in a String which is the name of the task. + */ + ToDo(String name) { + this.taskName = name; + this.isCompleted = false; + } + + @Override + public String toString() { + return "[T]" + super.toString(); + } +} diff --git a/src/main/java/Frenchie/Ui.java b/src/main/java/Frenchie/Ui.java new file mode 100644 index 0000000000..bcb5a13776 --- /dev/null +++ b/src/main/java/Frenchie/Ui.java @@ -0,0 +1,102 @@ +package Frenchie; + +import java.util.Scanner; + +/** + * This Ui Class deals with handling the user input returning respective success messages + * depending on the user input. + * This Ui class has a private Scanner attribute that takes in User input. + */ +public class Ui { + private Scanner scanner; + + /** + * Constructor that creates a new Ui object. + */ + public Ui() { + this.scanner = new Scanner(System.in); + } + + /** + * This method prints out all the tasks stored in a TaskList. + * @param tasks TaskList object that contains all the Tasks in an arraylist. + */ + public String listTasks(TaskList tasks) { + return tasks.listTasks(); + } + + /** + * This method prints out the success message that a Task in a tasklist has been marked as completed. + * @param target_task the Task to be marked as completed. + */ + public String markTaskAsComplete(Task target_task) { + return " Nice! I've marked this task as done: \n" + + target_task.toString() + "\n"; + } + + /** + * This method prints out the success message that a Task in a tasklist has been marked as incomplete. + * @param target_task the Task to be marked as incomplete. + */ + public String markTaskAsIncompelte(Task target_task) { + return " OK, I've marked this task as not done yet: \n" + + target_task.toString() + "\n"; + } + + /** + * This method prints out the success message when a Task has been added to the TaskList. + * @param task the Task object to be added to the TaskList. + * @param taskList the Tasklist that the Task should be added to. + */ + public String addTask(Task task, TaskList taskList) { + return " Got it! I've added this task: \n" + + task + "\n" + + "Now you have " + taskList.size() + " tasks in the list.\n"; + } + + /** + * This method prints out the success message when a Task has been removed from a TaskList. + * @param target_task the Task to be removed from the TaskList. + * @param taskList the TaskList that the Task should be removed from. + */ + public String deleteTask(Task target_task, TaskList taskList) { + return "Noted. I've removed this task: \n" + + target_task.toString() + "\n" + + "Now you have " + taskList.size() + " tasks in the list.\n"; + } + + /** + * This method prints out the exit message when a user inputs 'bye'. + */ + public String exitMessage() { + return "Bye. Hope to see you again soon!\n"; + } + + /** + * This method closes the Scanner of the Ui object when the chatbot should be closed. + */ + + public String findMessage() { + return "Here are the matching tasks in your list: \n"; + } + + public String helpMessage() { + String output = "Quickstart guide: \n" + + "You have 3 different tasks you can add to Frenchie: \n" + + " 1. todo taskname\n" + + " 2. deadline taskname /by dd/MM/yyyy HH:mm \n" + + " 3. event taskname /from dd/MM/yyyy HH:mm /to dd/MM/yyyy HH:mm \n" + + "Ensure you input the tasks in the above format for Frenchie to function as intended. \n" + + "Other functions include: \n" + + "list - To list all tasks stored in the TaskList \n" + + "mark taskIndex - mark the task of index taskIndex as done \n" + + "unmark taskIndex - mark the task of index taskIndex as incomplete \n" + + "delete taskIndex - delete the task of index taskIndex from the list \n" + + "find keyword - list out all tasks that contain the keyword in their task name"; + return output; + } + + public void closeScanner() { + scanner.close(); + } +} diff --git a/src/main/resources/images/FrenchieBot.jpeg b/src/main/resources/images/FrenchieBot.jpeg new file mode 100644 index 0000000000..3e7f30b45d Binary files /dev/null and b/src/main/resources/images/FrenchieBot.jpeg differ diff --git a/src/main/resources/images/FrenchieUser.jpg b/src/main/resources/images/FrenchieUser.jpg new file mode 100644 index 0000000000..58d0b76b78 Binary files /dev/null and b/src/main/resources/images/FrenchieUser.jpg differ diff --git a/src/main/resources/view/DialogBox.fxml b/src/main/resources/view/DialogBox.fxml new file mode 100644 index 0000000000..59d16ac91a --- /dev/null +++ b/src/main/resources/view/DialogBox.fxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml new file mode 100644 index 0000000000..9c70ebdea9 --- /dev/null +++ b/src/main/resources/view/MainWindow.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + +