diff --git a/.gitignore b/.gitignore index 2873e189e1..81bf2966d3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,9 @@ /*.iml # Gradle build files -/.gradle/ /build/ src/main/resources/docs/ +/.gradle/ # MacOS custom attributes files created by Finder .DS_Store @@ -15,3 +15,7 @@ bin/ /text-ui-test/ACTUAL.TXT text-ui-test/EXPECTED-UNIX.TXT +*.class +token +*.txt + diff --git a/.gradle/6.2/executionHistory/executionHistory.bin b/.gradle/6.2/executionHistory/executionHistory.bin new file mode 100644 index 0000000000..3ec70160d8 Binary files /dev/null and b/.gradle/6.2/executionHistory/executionHistory.bin differ diff --git a/.gradle/6.2/executionHistory/executionHistory.lock b/.gradle/6.2/executionHistory/executionHistory.lock new file mode 100644 index 0000000000..d17218e425 Binary files /dev/null and b/.gradle/6.2/executionHistory/executionHistory.lock differ diff --git a/.gradle/6.2/fileChanges/last-build.bin b/.gradle/6.2/fileChanges/last-build.bin new file mode 100644 index 0000000000..f76dd238ad Binary files /dev/null and b/.gradle/6.2/fileChanges/last-build.bin differ diff --git a/.gradle/6.2/fileContent/fileContent.lock b/.gradle/6.2/fileContent/fileContent.lock new file mode 100644 index 0000000000..944352baae Binary files /dev/null and b/.gradle/6.2/fileContent/fileContent.lock differ diff --git a/.gradle/6.2/fileHashes/fileHashes.bin b/.gradle/6.2/fileHashes/fileHashes.bin new file mode 100644 index 0000000000..e7f77b3309 Binary files /dev/null and b/.gradle/6.2/fileHashes/fileHashes.bin differ diff --git a/.gradle/6.2/fileHashes/fileHashes.lock b/.gradle/6.2/fileHashes/fileHashes.lock new file mode 100644 index 0000000000..be1c1b395b Binary files /dev/null and b/.gradle/6.2/fileHashes/fileHashes.lock differ diff --git a/.gradle/6.2/gc.properties b/.gradle/6.2/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.gradle/6.2/javaCompile/classAnalysis.bin b/.gradle/6.2/javaCompile/classAnalysis.bin new file mode 100644 index 0000000000..a683738bbd Binary files /dev/null and b/.gradle/6.2/javaCompile/classAnalysis.bin differ diff --git a/.gradle/6.2/javaCompile/javaCompile.lock b/.gradle/6.2/javaCompile/javaCompile.lock new file mode 100644 index 0000000000..327c96f57e Binary files /dev/null and b/.gradle/6.2/javaCompile/javaCompile.lock differ diff --git a/.gradle/6.2/javaCompile/taskHistory.bin b/.gradle/6.2/javaCompile/taskHistory.bin new file mode 100644 index 0000000000..d8c272645d Binary files /dev/null and b/.gradle/6.2/javaCompile/taskHistory.bin differ diff --git a/.gradle/7.6/checksums/checksums.lock b/.gradle/7.6/checksums/checksums.lock new file mode 100644 index 0000000000..d821876c29 Binary files /dev/null and b/.gradle/7.6/checksums/checksums.lock differ diff --git a/.gradle/7.6/checksums/md5-checksums.bin b/.gradle/7.6/checksums/md5-checksums.bin new file mode 100644 index 0000000000..7f375c5cbe Binary files /dev/null and b/.gradle/7.6/checksums/md5-checksums.bin differ diff --git a/.gradle/7.6/checksums/sha1-checksums.bin b/.gradle/7.6/checksums/sha1-checksums.bin new file mode 100644 index 0000000000..f4b394966f Binary files /dev/null and b/.gradle/7.6/checksums/sha1-checksums.bin differ diff --git a/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000000..31c9b6757c Binary files /dev/null and b/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/7.6/dependencies-accessors/gc.properties b/.gradle/7.6/dependencies-accessors/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.gradle/7.6/executionHistory/executionHistory.bin b/.gradle/7.6/executionHistory/executionHistory.bin new file mode 100644 index 0000000000..e2a046c759 Binary files /dev/null and b/.gradle/7.6/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.6/executionHistory/executionHistory.lock b/.gradle/7.6/executionHistory/executionHistory.lock new file mode 100644 index 0000000000..6121f043a0 Binary files /dev/null and b/.gradle/7.6/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.6/fileChanges/last-build.bin b/.gradle/7.6/fileChanges/last-build.bin new file mode 100644 index 0000000000..f76dd238ad Binary files /dev/null and b/.gradle/7.6/fileChanges/last-build.bin differ diff --git a/.gradle/7.6/fileHashes/fileHashes.bin b/.gradle/7.6/fileHashes/fileHashes.bin new file mode 100644 index 0000000000..2fdbb1f98e Binary files /dev/null and b/.gradle/7.6/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.6/fileHashes/fileHashes.lock b/.gradle/7.6/fileHashes/fileHashes.lock new file mode 100644 index 0000000000..3e547e077d Binary files /dev/null and b/.gradle/7.6/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.6/fileHashes/resourceHashesCache.bin b/.gradle/7.6/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000000..4737eb114c Binary files /dev/null and b/.gradle/7.6/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/7.6/gc.properties b/.gradle/7.6/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000000..3d90b34b79 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000000..1b18655523 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Mon Feb 13 23:09:40 PST 2023 +gradle.version=6.2 diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock new file mode 100644 index 0000000000..a7d7b694ac Binary files /dev/null and b/.gradle/checksums/checksums.lock differ diff --git a/.gradle/checksums/md5-checksums.bin b/.gradle/checksums/md5-checksums.bin new file mode 100644 index 0000000000..d8b799b155 Binary files /dev/null and b/.gradle/checksums/md5-checksums.bin differ diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin new file mode 100644 index 0000000000..82bec7fe50 Binary files /dev/null and b/.gradle/checksums/sha1-checksums.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe new file mode 100644 index 0000000000..eebbf1ddbf Binary files /dev/null and b/.gradle/file-system.probe differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/README.md b/README.md index 8715d4d915..4ca09fb198 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,68 @@ -# 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 - ____ _ - | _ \ _ _| | _____ - | | | | | | | |/ / _ \ - | |_| | |_| | < __/ - |____/ \__,_|_|\_\___| - ``` +# Task Manager User Guide + +This task manager allows you to organize and manage your tasks efficiently. Here are the commands you can use: + +## Adding Tasks + +### Todo +To add a todo task, use the following command: +```todo ``` + +Replace `` with the details of your todo task. + +### Event +To add an event task with a specified date range, use the following command: +``` event /from /to ``` + +Replace `` with the event details and `` with the start and end dates. + +### Deadline +To add a deadline task with a specified due date, use the following command: +```deadline /by ``` + +Replace `` with the task details and `` with the due date. + +## Listing Tasks +To view the list of tasks, simply use the command: +```list``` + + +## Managing Tasks + +### Marking a Task as Done +To mark a task as done, use the following command: +```mark ``` + +Replace `` with the index of the task in the list. + +### Unmarking a Task +To unmark a task, use the following command: +```unmark ``` + +### Deleting a Task +To remove a task from the list, use the following command: +```delete ``` + +Replace `` with the index of the task in the list. + +## Searching for Tasks +To find a task in the list using a keyword, use the following command: + +```find ``` + +Replace `` with the search term. + +## Undoing the Latest Action +To undo the most recent action, use the command: +```undo``` + + +## Additional Features + +### Saving Tasks +Tasks are automatically saved in a file named `duke.txt` in the current directory. + +Make sure to check the file for your tasks or to transfer them to another device. + +--- + diff --git a/ReportVersion.java b/ReportVersion.java new file mode 100644 index 0000000000..f8a3df3018 --- /dev/null +++ b/ReportVersion.java @@ -0,0 +1,9 @@ +import javafx.application.Application; +import javafx.stage.Stage; +public class ReportVersion extends Application { + public static void main(String[] args) { launch(args); } + @Override public void start(Stage stage) { + System.out.println("javafx.runtime.version: " + System.getProperties().get("javafx.runtime.version")); + System.exit(0); + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000000..239f80d14e --- /dev/null +++ b/build.gradle @@ -0,0 +1,45 @@ +plugins { + id 'java' + id 'application' + id 'checkstyle' + id 'com.github.johnrengelman.shadow' version '5.1.0' +} + +checkstyle { + toolVersion = '10.2' +} + +repositories { + mavenCentral() +} + +dependencies { + String javaFxVersion = '11' + + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac' + implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux' + testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.5.0' + testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.5.0' +} + +test { + useJUnitPlatform() +} + +application { + mainClassName = "duke.Launcher" +} + +run{ + standardInput = System.in +} diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml new file mode 100644 index 0000000000..d618671b83 --- /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..c7e467e7bb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,29 +1,31 @@ # User Guide -## Features +## Add 3 types of tasks -### Feature-ABC +### Task can be added as: -Description of the feature. +> * todo \ +> * event \ /from \ /to \ +> * deadline \ /by \ -### Feature-XYZ +### Task can be listed by saying: +> "list" -Description of the feature. +## Task can be marked using their index in the list: +> * mark 1 +> * unmark 1 -## Usage +### `Keyword` - list of commands -### `Keyword` - Describe action +1. todo - makes a todo task +2. event - makes event task +3. deadline - makes event task +4. list - shows list of task +5. mark - marks task as done (by index) +6. unmark - unmarks task (by index) +7. delete - removes task from list (by index) +8. find - searches for task in list by a single keyword +9. undo - undoes the most latest action -Describe the action and its outcome. - -Example of usage: - -`keyword (optional arguments)` - -Expected outcome: - -Description of the outcome. - -``` -expected output -``` +### Additional features: +saves tasks in file, ./duke.txt diff --git a/docs/Ui.png b/docs/Ui.png new file mode 100644 index 0000000000..967d184f66 Binary files /dev/null and b/docs/Ui.png differ diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..f3d88b1c2f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..b7c8c5dbf5 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..2fe81a7d95 --- /dev/null +++ b/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000000..62bd9b9cce --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,103 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/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/DialogBox.java b/src/main/java/duke/DialogBox.java new file mode 100644 index 0000000000..975c6eb306 --- /dev/null +++ b/src/main/java/duke/DialogBox.java @@ -0,0 +1,61 @@ +package 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; + +/** + * 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(duke.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.java b/src/main/java/duke/Duke.java new file mode 100644 index 0000000000..dbbda543f7 --- /dev/null +++ b/src/main/java/duke/Duke.java @@ -0,0 +1,60 @@ +package duke; +import java.io.*; +import java.util.*; + +import duke.command.*; +/** + * main duke class. helps abstract all the other components by calling their methods + */ +public class Duke { + private static Ui ui; //deal with user interactionss + private static TaskList taskList; + private static Storage storage; + + public Duke() { + String filePath = "./duke.txt"; + this.ui = new Ui(); + this.storage = new Storage(filePath); + try { + this.taskList = new TaskList(storage.load()); + } catch (DukeException e) { + ui.showLoadingError(); + this.taskList = new TaskList(); + } + } + public String getResponse(String input) { + String response = ""; + try { + response = ui.parseIn(input, taskList, ui, storage); + this.storage.save(taskList); + assert response instanceof String : "Response not a String"; + return response; + } catch (Exception e) { + return e.toString(); + } + + } + //just in case still want to run cli version + public static void main(String[] args) throws DukeException, IOException { + Duke duke = new Duke(); + duke.ui.printLogo(); + while (true) { + System.out.print('\n'); + Scanner sc = new Scanner(System.in); + String in = sc.nextLine(); + if (in.equals("bye")) { + System.out.println("No don't go!!"); + break; + } + ui.line(in.length()); + try { + Command c = Parser.parseIn(in); + c.execute(taskList, ui, storage); + duke.storage.save(taskList); + } catch (DukeException e) { + //empty catch, error should have been handled by parser or command + } + ui.line(in.length()); + } + } +} diff --git a/src/main/java/duke/DukeException.java b/src/main/java/duke/DukeException.java new file mode 100644 index 0000000000..85e776f955 --- /dev/null +++ b/src/main/java/duke/DukeException.java @@ -0,0 +1,33 @@ +package duke; +import java.io.FileNotFoundException; + +/** + * handles abstraction + */ +public class DukeException extends Exception { + + public DukeException() { + super("idk what you are saying"); + } + public DukeException(String problem) { + super(problem); + } + public DukeException(Throwable cause) { + super(cause.toString()); + } + public DukeException(IllegalArgumentException i) { + super("did you forget a keyword? ie /by /to /from"); + } + public DukeException(FileNotFoundException i) { + super("File not found"); + } + public DukeException(IndexOutOfBoundsException i) { + super("Did you try to mark a task that is not in the list?"); + } + public DukeException(NumberFormatException i) { + super("You must input a number"); + } + public String toString() { + return String.format(super.getMessage()); + } +} diff --git a/src/main/java/duke/Launcher.java b/src/main/java/duke/Launcher.java new file mode 100644 index 0000000000..6f877372d7 --- /dev/null +++ b/src/main/java/duke/Launcher.java @@ -0,0 +1,10 @@ +package 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/MANIFEST.MF b/src/main/java/duke/MANIFEST.MF new file mode 100644 index 0000000000..6e7f2f907a --- /dev/null +++ b/src/main/java/duke/MANIFEST.MF @@ -0,0 +1,2 @@ +Main-Class: duke.Duke + diff --git a/src/main/java/duke/Main.java b/src/main/java/duke/Main.java new file mode 100644 index 0000000000..9f910fbe1a --- /dev/null +++ b/src/main/java/duke/Main.java @@ -0,0 +1,31 @@ +package 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); + 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..64e6c58119 --- /dev/null +++ b/src/main/java/duke/MainWindow.java @@ -0,0 +1,52 @@ +package 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 MainWindow. Provides the layout for the other controls. + */ +public class MainWindow extends AnchorPane { + @FXML + private ScrollPane scrollPane; + @FXML + private VBox dialogContainer; + @FXML + private TextField userInput; + @FXML + private Button sendButton; + + private Duke duke; + + private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.png")); + private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png")); + + @FXML + public void initialize() { + scrollPane.vvalueProperty().bind(dialogContainer.heightProperty()); + } + + public void setDuke(Duke d) { + duke = d; + } + + /** + * 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..e6ad9b6e56 --- /dev/null +++ b/src/main/java/duke/Parser.java @@ -0,0 +1,35 @@ +package duke; +import java.io.*; +import java.util.*; + +import duke.command.*; +/** + * helps parse the user input and return the corresponding object + */ +public class Parser { + public static Command parseIn(String in) throws DukeException { + String[] parmArr = in.split("\\s+"); + List parm = Arrays.asList(parmArr); + CommandEnum command = CommandEnum.fromString(parm.get(0)); + switch(command) { + case LIST: + return new UiCommand(); + case TODO: + case DEADLINE: + case EVENT: + return new AddCommand(command, parm.subList(1, parm.size())); + case MARK: + return new MarkCommand(Integer.parseInt(parm.get(1)), true); + case UNMARK: + return new MarkCommand(Integer.parseInt(parm.get(1)), false); + case DELETE: + return new DeleteCommand(Integer.parseInt(parm.get(1))); + case FIND: + return new FindCommand(parm.subList(1, parm.size())); + case UNDO: + return new UndoCommand(); + default: + throw new DukeException(); + } + } +} diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java new file mode 100644 index 0000000000..2e9cb063b1 --- /dev/null +++ b/src/main/java/duke/Storage.java @@ -0,0 +1,93 @@ +package duke; + +import java.io.*; +import java.util.*; + +import duke.command.*; +import duke.task.*; + +/** + * handles the loading and storing onto external file + */ +public class Storage { + private static ArrayList list; + private String filePath; + private File save; + + public Storage(String filePath) { + this.list = new ArrayList<>(); + this.save = new File(filePath); + this.filePath = filePath; + } + + public ArrayList load() throws DukeException { + this.save = new File(filePath); + if (save.exists()) { + try { + BufferedReader reader = new BufferedReader(new FileReader(save)); + writeTo(reader); + reader.close(); + } catch (Exception e) { + throw new DukeException("save file is blank"); + } + return this.list; + } else { + throw new DukeException("save file is blank"); + } + } + + private void writeTo(BufferedReader reader) throws Exception { + String line = reader.readLine(); + String[] parmArr = line.split("\\|"); + List parm = Arrays.asList(parmArr); + while (line != null) { + parmArr = line.split("\\|"); + parm = Arrays.asList(parmArr); + CommandEnum command = CommandEnum.fromTag(parm.get(0)); + boolean isMark = parm.get(1).equals("1"); + String description = parm.get(2); + switch (command) { + case TODO: + list.add(new Todo(description, isMark)); + break; + case DEADLINE: + String date = parm.get(3); + list.add(new Deadline(description, date, isMark)); + break; + case EVENT: + String from = parm.get(3); + String to = parm.get(4); + list.add(new Event(description, from, to, isMark)); + break; + default: + break; + } + line = reader.readLine(); + } + } + + public void save(TaskList taskList) throws DukeException, IOException { + this.list = taskList.getList(); + save.delete(); + File saver = new File("./duke.txt"); + FileWriter mySaveWriter = new FileWriter(saver, false); + try { + for (Task i: list) { + String tag = i.getTag(); + String mark = i.getStatusIcon(); + if (mark == "X") { + mark = "1"; + } else { + mark = "0"; + } + String description = i.getDescription(); + String date = i.getDate(); + mySaveWriter.write(tag + "|" + mark + "|" + description + "|" + date + "\n"); + } + mySaveWriter.flush(); + mySaveWriter.close(); + } catch (Exception e) { + throw new DukeException(e); + } + } +} diff --git a/src/main/java/duke/TaskList.java b/src/main/java/duke/TaskList.java new file mode 100644 index 0000000000..e0f8f81d56 --- /dev/null +++ b/src/main/java/duke/TaskList.java @@ -0,0 +1,100 @@ +package duke; +import java.util.*; + +import duke.task.*; + +/** + * stores and handles edits to current session task list + */ +public class TaskList { + private static ArrayList list; + private static ArrayList prevList; + private int markOrListCommand; //last action was mark = 1, last action was a list action = 0 + private int markedTask; + private boolean isMark; + + public TaskList() { + this.list = new ArrayList<>(); + this.prevList = list; + } + public TaskList(ArrayList list) { + this.list = list; + this.prevList = list; + } + private void logList() { + this.prevList = new ArrayList<>(list); + } + private void logMark(int i, boolean b) { + this.markedTask = i; + this.isMark = !b; + } + public ArrayList getList() { + return this.list; + } + public String showList() { + String response = ""; + int j = 0; + for (Task i: list) { + j++; + response = response + String.valueOf(j) + ". " + i + "\n"; + } + return response; + } + /** + * Marks task according to boolean + * + * @param i task to remove + * @param b boolean whether it is to be marked or un mark + */ + public String markTask(int i, boolean b) { + logMark(i, b); + markOrListCommand = 1; + int index = i - 1; + list.get(index).markTask(b); + return "Marked/Unmarked the task, task is in the state:\n" + " " + list.get(index); + } + /** + * add task to list + * + * @param task task to be added to list + */ + public String addList(Task task) { + markOrListCommand = 0; + logList(); + list.add(task); + return "added: " + task.getDescription() + "\n You have: " + list.size() + " task(s)\n"; + + } + /** + * remeove task to list + * + * @param i task to be added to list + */ + public String deleteTask(int i) { + markOrListCommand = 0; + logList(); + int index = i - 1; + String response = ""; + response = "removed: " + list.get(index).toString() + "\n You have: " + (list.size() - 1) + " task(s)\n"; + list.remove(index); + return response; + } + public String find(String word) { + StringBuilder display = new StringBuilder(); + for (int i = 0; i < this.list.size(); i++) { + Task curr = this.list.get(i); + if (curr.toString().toLowerCase().contains(word.toLowerCase())) { + display.append((curr) + ". " + curr.getStatusIcon() + "\n"); + } + } + return display.toString(); + } + public String undo() { + if (markOrListCommand == 0) { + this.list = new ArrayList<>(this.prevList); + } else { + markTask(markedTask, isMark); + } + return "Previous command undone (at most only most recent command can be undone)"; + } +} diff --git a/src/main/java/duke/Ui.java b/src/main/java/duke/Ui.java new file mode 100644 index 0000000000..e8da25d83c --- /dev/null +++ b/src/main/java/duke/Ui.java @@ -0,0 +1,45 @@ +package duke; + +import duke.command.Command; +/** + * handles Ui interactions + */ +public class Ui { + public Ui() { + //UI does not need to store anything + } + public void printLogo() { + //CHECKSTYLE.OFF: checkStyleTest + String logo = " ____ _ \n" + + "| _ \\ _ _| | _____ \n" + + "| | | | | | | |/ / _ \\\n" + + "| |_| | |_| | < __/\n" + + "|____/ \\__,_|_|\\_\\___|\n"; + //CHECKSTYLE.ON: checkStyleTest + System.out.println("Hello from\n" + logo); + } + public void showLoadingError() { + System.out.println("error loading file"); + } + public void line(int l) { + System.out.print('\n'); + for (int i = 0; i < l + 15; i++) { + System.out.print('_'); + } + System.out.print('\n'); + } + public String parseIn(String in, TaskList taskList, Ui ui, Storage storage) { + try { + Command c = Parser.parseIn(in); + return c.execute(taskList, ui, storage); + } catch (DukeException e) { + return e.toString(); + } + } + public String showList(TaskList taskList) { + return taskList.showList(); + } + public void print(String word) { + System.out.println(word); + } +} diff --git a/src/main/java/duke/command/.gradle/6.2/fileChanges/last-build.bin b/src/main/java/duke/command/.gradle/6.2/fileChanges/last-build.bin new file mode 100644 index 0000000000..f76dd238ad Binary files /dev/null and b/src/main/java/duke/command/.gradle/6.2/fileChanges/last-build.bin differ diff --git a/src/main/java/duke/command/.gradle/6.2/fileHashes/fileHashes.lock b/src/main/java/duke/command/.gradle/6.2/fileHashes/fileHashes.lock new file mode 100644 index 0000000000..ba5f7e3a5c Binary files /dev/null and b/src/main/java/duke/command/.gradle/6.2/fileHashes/fileHashes.lock differ diff --git a/src/main/java/duke/command/.gradle/6.2/gc.properties b/src/main/java/duke/command/.gradle/6.2/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/duke/command/.gradle/checksums/checksums.lock b/src/main/java/duke/command/.gradle/checksums/checksums.lock new file mode 100644 index 0000000000..776cd53f24 Binary files /dev/null and b/src/main/java/duke/command/.gradle/checksums/checksums.lock differ diff --git a/src/main/java/duke/command/.gradle/vcs-1/gc.properties b/src/main/java/duke/command/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/duke/command/AddCommand.java b/src/main/java/duke/command/AddCommand.java new file mode 100644 index 0000000000..dfe8d889bb --- /dev/null +++ b/src/main/java/duke/command/AddCommand.java @@ -0,0 +1,65 @@ +package duke.command; +import java.util.List; + +import duke.*; +import duke.task.*; +public class AddCommand extends Command { + private CommandEnum command; + private List arg; + + public AddCommand(CommandEnum command, List arg) { + this.command = command; + this.arg = arg; + } + @Override + public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { + switch(this.command) { + case TODO: + if (arg.size() == 0) { + assert arg.size() > 0; + throw new DukeException("TASK MUST HAS DESCRIPSHUN MEOW"); + } + String description = String.join(" ", arg); + return taskList.addList(new Todo(description)); + case DEADLINE: + try { + return deadline(taskList, ui, storage); + } catch (IllegalArgumentException e) { + throw new DukeException(e); + } catch (Exception e) { + throw new DukeException(e); + } + case EVENT: + try { + return event(taskList, ui, storage); + } catch (IllegalArgumentException e) { + throw new DukeException(e); + } catch (Exception e) { + throw new DukeException(e); + } + default: + return "idk what you are saying"; + } + } + private String deadline(TaskList taskList, Ui ui, Storage storage) throws DukeException { + int byIndex = arg.indexOf("/by"); + List commandTempArg = arg.subList(1, byIndex); + String description = String.join(" ", commandTempArg); + commandTempArg = arg.subList(byIndex + 1, arg.size()); + String deadline = String.join(" ", commandTempArg); + return taskList.addList(new Deadline(description, deadline)); + } + private String event(TaskList taskList, Ui ui, Storage storage) throws DukeException { + int fromIndex = arg.indexOf("/from"); + int toIndex = arg.indexOf("/to"); + List commandTempArg = arg.subList(1, fromIndex); + String description = String.join(" ", commandTempArg); + List f = arg.subList(fromIndex + 1, toIndex); //f is temp to pass into join func + String fDescription = String.join(" ", f); + List t = arg.subList(toIndex + 1, arg.size()); //t is temp to pass into join func + String tDescription = String.join(" ", commandTempArg); + tDescription = String.join(" ", t); + return taskList.addList(new Event(description, fDescription, tDescription)); + } +} + diff --git a/src/main/java/duke/command/Command.java b/src/main/java/duke/command/Command.java new file mode 100644 index 0000000000..f0f19f9043 --- /dev/null +++ b/src/main/java/duke/command/Command.java @@ -0,0 +1,5 @@ +package duke.command; +import duke.*; +public abstract class Command { + public abstract String execute(TaskList tasks, Ui ui, Storage storage) throws DukeException; +} diff --git a/src/main/java/duke/command/CommandEnum.java b/src/main/java/duke/command/CommandEnum.java new file mode 100644 index 0000000000..6c1f240c53 --- /dev/null +++ b/src/main/java/duke/command/CommandEnum.java @@ -0,0 +1,41 @@ +package duke.command; +public enum CommandEnum { + LIST("list", ""), + TODO("todo", "[T]"), + DEADLINE("deadline", "[D]"), + EVENT("event", "[E]"), + DELETE("delete", ""), + MARK("mark", ""), + FIND("find", ""), + UNDO("undo", ""), + SOMETHINGELSE("", ""), + UNMARK("unmark", ""); + private final String description; + private final String tag; + CommandEnum(String description, String tag) { + this.description = description; + this.tag = tag; + } + public String getString() { + return this.description; + } + public String getTag() { + return this.tag; + } + public static CommandEnum fromString(String text) { + for (CommandEnum b : CommandEnum.values()) { + if (b.getString().equalsIgnoreCase(text)) { + return b; + } + } + return SOMETHINGELSE; + } + public static CommandEnum fromTag(String tag) { + for (CommandEnum b : CommandEnum.values()) { + if (b.getTag().equals(tag)) { + return b; + } + } + return SOMETHINGELSE; + } +} diff --git a/src/main/java/duke/command/DeleteCommand.java b/src/main/java/duke/command/DeleteCommand.java new file mode 100644 index 0000000000..a28b16e411 --- /dev/null +++ b/src/main/java/duke/command/DeleteCommand.java @@ -0,0 +1,19 @@ +package duke.command; +import duke.*; +public class DeleteCommand extends Command { + private int taskInt; + public DeleteCommand(int taskInt) { + this.taskInt = taskInt; + } + public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { + try { + return taskList.deleteTask(taskInt); + } catch (IndexOutOfBoundsException e) { + throw new DukeException(e); + } catch (NumberFormatException e) { + throw new DukeException(e); + } catch (Exception e) { + throw new DukeException(e); + } + } +} diff --git a/src/main/java/duke/command/FindCommand.java b/src/main/java/duke/command/FindCommand.java new file mode 100644 index 0000000000..f68fb25d86 --- /dev/null +++ b/src/main/java/duke/command/FindCommand.java @@ -0,0 +1,19 @@ +package duke.command; +import java.util.List; + +import duke.*; +import duke.task.*; +public class FindCommand extends Command { + private List arg; + + public FindCommand(List arg) { + this.arg = arg; + } + public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { + if (this.arg.size() > 1) { + throw new DukeException("only seaches by ONE keyword"); + } + return taskList.find(arg.get(0)); + } +} + diff --git a/src/main/java/duke/command/MarkCommand.java b/src/main/java/duke/command/MarkCommand.java new file mode 100644 index 0000000000..1c27bfa740 --- /dev/null +++ b/src/main/java/duke/command/MarkCommand.java @@ -0,0 +1,21 @@ +package duke.command; +import duke.*; +public class MarkCommand extends Command { + private int taskInt; + private boolean isMarked; + public MarkCommand(int taskInt, boolean isMarked) { + this.taskInt = taskInt; + this.isMarked = isMarked; + } + public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { + try { + return taskList.markTask(taskInt, isMarked); + } catch (IndexOutOfBoundsException e) { + throw new DukeException(e); + } catch (NumberFormatException e) { + throw new DukeException(e); + } catch (Exception e) { + throw new DukeException(e); + } + } +} diff --git a/src/main/java/duke/command/UiCommand.java b/src/main/java/duke/command/UiCommand.java new file mode 100644 index 0000000000..632850a65b --- /dev/null +++ b/src/main/java/duke/command/UiCommand.java @@ -0,0 +1,9 @@ +package duke.command; +import duke.*; +public class UiCommand extends Command { + public UiCommand() { + } + public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { + return ui.showList(taskList); + } +} diff --git a/src/main/java/duke/command/UndoCommand.java b/src/main/java/duke/command/UndoCommand.java new file mode 100644 index 0000000000..7aa1721281 --- /dev/null +++ b/src/main/java/duke/command/UndoCommand.java @@ -0,0 +1,12 @@ +package duke.command; +import java.util.List; + +import duke.*; +import duke.task.*; +public class UndoCommand extends Command { + + public String execute(TaskList taskList, Ui ui, Storage storage) throws DukeException { + return taskList.undo(); + } +} + diff --git a/src/main/java/duke/dukeV0.1.jar b/src/main/java/duke/dukeV0.1.jar new file mode 100644 index 0000000000..3bbce50d61 Binary files /dev/null and b/src/main/java/duke/dukeV0.1.jar differ diff --git a/src/main/java/duke/task/Deadline.java b/src/main/java/duke/task/Deadline.java new file mode 100644 index 0000000000..8dd9c13dfd --- /dev/null +++ b/src/main/java/duke/task/Deadline.java @@ -0,0 +1,46 @@ +package duke.task; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Optional; +public class Deadline extends Task { + + protected Optional by; + protected String strBy; + protected String tag; + public Deadline(String description, String strDate) { + super(description); + this.tag = "[D]"; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + try { + this.by = Optional.of(LocalDate.parse(strDate, formatter)); + } catch (Exception e) { + this.strBy = strDate; + } + } + public Deadline(String description, String strDate, boolean isMark) { + super(description); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + try { + this.by = Optional.of(LocalDate.parse(strDate, formatter)); + } catch (Exception e) { + this.strBy = strDate; + } + this.tag = "[D]"; + super.markTask(isMark); + } + public String getDate() { + if (strBy == null) { + DateTimeFormatter date = DateTimeFormatter.ofPattern("MMM dd yyyy"); + String formattedDate = this.by.get().format(date); + return formattedDate; + } + return strBy; + } + public String getTag() { + return this.tag; + } + @Override + public String toString() { + return this.tag + super.toString() + " (by: " + this.getDate() + ")"; + } +} diff --git a/src/main/java/duke/task/Event.java b/src/main/java/duke/task/Event.java new file mode 100644 index 0000000000..00abcb65af --- /dev/null +++ b/src/main/java/duke/task/Event.java @@ -0,0 +1,63 @@ +package duke.task; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +public class Event extends Task { + + protected Optional to; + protected Optional from; + protected String strFrom; + protected String strTo; + protected String tag; + public Event(String description, String from, String to) { + super(description); + this.tag = "[E]"; + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + try { + this.from = Optional.of(LocalDate.parse(from, formatter)); + this.to = Optional.of(LocalDate.parse(to, formatter)); + } catch (Exception e) { + this.strTo = to; + this.strFrom = from; + } + } + + + public Event(String description, String from, String to, boolean isMark) { + super(description); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + try { + this.from = Optional.of(LocalDate.parse(from, formatter)); + this.to = Optional.of(LocalDate.parse(to, formatter)); + } catch (Exception e) { + this.strTo = to; + this.strFrom = from; + } + this.tag = "[E]"; + if (isMark) { + super.markTask(isMark); + } + } + + public String getDate() { + if (strTo == null) { + DateTimeFormatter date = DateTimeFormatter.ofPattern("MMM dd yyyy"); + String formattedFrom = this.from.get().format(date); + String formattedTo = this.to.get().format(date); + return formattedFrom + "|" + formattedTo; + } + return strFrom + "|" + strTo; + } + + public String getTag() { + return this.tag; + } + + @Override + public String toString() { + String line = this.getDate(); + String[] parmArr = line.split("\\|"); + List parm = Arrays.asList(parmArr); + return this.getTag() + super.toString() + " (from:" + parm.get(0) + " to:" + parm.get(1) + ")"; + } +} diff --git a/src/main/java/duke/task/Task.java b/src/main/java/duke/task/Task.java new file mode 100644 index 0000000000..c4a73410c3 --- /dev/null +++ b/src/main/java/duke/task/Task.java @@ -0,0 +1,26 @@ +package duke.task; +public abstract class Task { + protected String description; + protected boolean isDone; + public abstract String getTag(); + public abstract String getDate(); + + public Task(String description) { + this.description = description; + this.isDone = false; + } + + public String getStatusIcon() { + return (isDone ? "X" : " "); + } + public String getDescription() { + return description; + } + public void markTask(boolean b) { + isDone = b; + } + @Override + public String toString() { + return "[" + getStatusIcon() + "] " + description; + } +} diff --git a/src/main/java/duke/task/Todo.java b/src/main/java/duke/task/Todo.java new file mode 100644 index 0000000000..3bb036f4f3 --- /dev/null +++ b/src/main/java/duke/task/Todo.java @@ -0,0 +1,24 @@ +package duke.task; +public class Todo extends Task { + + protected String tag; + public Todo(String description) { + super(description); + this.tag = "[T]"; + } + public Todo(String description, boolean isMark) { + super(description); + this.tag = "[T]"; + super.markTask(isMark); + } + public String getTag() { + return this.tag; + } + public String getDate() { + return ""; + } + @Override + public String toString() { + return this.tag + super.toString(); + } +} 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..e433809947 --- /dev/null +++ b/src/main/resources/view/DialogBox.fxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml new file mode 100644 index 0000000000..832f84382e --- /dev/null +++ b/src/main/resources/view/MainWindow.fxml @@ -0,0 +1,19 @@ + + + + + + + + + + + +