diff --git a/README.md b/README.md
index 8715d4d915..514d51739b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Duke project template
+# charlie.ui.Charlie 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.
@@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
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:
+3. After that, locate the `src/main/java/charlie.ui.Charlie.java` file, right-click it, and choose `Run charlie.ui.Charlie.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..6245bb6703
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,46 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'com.github.johnrengelman.shadow' version '7.1.2'
+ id 'org.openjfx.javafxplugin' version '0.0.10'
+}
+
+shadowJar {
+ archiveFileName = 'charlie.jar'
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ String javaFxVersion = '17.0.7'
+ implementation 'com.google.guava:guava:30.1-jre'
+ 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.10.0'
+ testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.10.0'
+}
+
+javafx {
+ version = "17" // Use the version compatible with your JDK
+ modules = [ 'javafx.controls', 'javafx.fxml' ]
+}
+
+test {
+ useJUnitPlatform()
+}
+
+application {
+ mainClass.set("charlie.Charlie")
+}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000000..acac1a8e28
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,434 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/checkstyle/suppressions.xml b/config/checkstyle/suppressions.xml
new file mode 100644
index 0000000000..135ea49ee0
--- /dev/null
+++ b/config/checkstyle/suppressions.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/charlie.txt b/data/charlie.txt
new file mode 100644
index 0000000000..b5511213f0
--- /dev/null
+++ b/data/charlie.txt
@@ -0,0 +1,9 @@
+<<<<<<< HEAD
+T | 1 | borrow book
+D | 0 | 5 | return book | Sunday
+T | 0 | 6 | go to the zoo
+E | 0 | 10 | hangout | 6pm | 10pm
+T | 0 | 10 | say bye to heather
+=======
+
+>>>>>>> C-priority
diff --git a/docs/README.md b/docs/README.md
index 8077118ebe..2885712c39 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,29 +1,201 @@
-# User Guide
+# Charlie User Guide
+
## Features
-### Feature-ABC
+### Feature-Add Todo Tasks
+
+It is possible to add todo tasks, these
+don't require a deadline or any sort of
+timing information
+
+You will be prompted to assign a priority
+to this task depending on how important it is
+
+### Feature-Add Deadline Tasks
+
+It is possible to add deadline tasks, these
+don't require a time by which the deadline is
+due
+
+You will be prompted to assign a priority
+to this task depending on how important it is
+
+### Feature-Add Event Tasks
+
+It is possible to add event tasks, these
+require times by which the event starts and ends
+
+You will be prompted to assign a priority
+to this task depending on how important it is
+
+### Feature-Find Keyword
-Description of the feature.
+It is possible to find tasks related to keywords,
+this can help with prioritisation of tasks such
+as "study" or "party"
-### Feature-XYZ
+### Feature-Delete Tasks
-Description of the feature.
+It is possible to delete tasks if an accident
+occurred, such as you inputted a task you
+don't actually have to complete
+
+### Feature-List Tasks
+
+It is possible to list tasks and view whether
+or not the task has been completed and its
+priority status
+
+### Feature-Mark Tasks
+
+It is possible to mark tasks once you finish
+a task but still want to be able to look at it
+
+### Feature-Unmark Tasks
+
+It is possible to unmark tasks if you thought
+you had finished but hadn't actually finished
## Usage
-### `Keyword` - Describe action
+### `todo` - creates a todo task
-Describe the action and its outcome.
+creates a todo task which requires no
+additional information, except for task
+description, you will be subsequently
+prompted for prioritisation of the task
Example of usage:
-`keyword (optional arguments)`
+`todo borrow book`
+
+(assume prioritisation is 1)
+
+Expected outcome:
+
+```
+Got it. I've added this task:
+ [T][ ][1] borrow book
+```
+
+### `deadline` - creates a deadline task
+
+creates a deadline task which requires
+the task description and the time by which
+the deadline is due, you will be subsequently
+prompted for prioritisation of the task
+
+Example of usage:
+
+`deadline party /by Sunday`
+
+(assume prioritisation is 1)
+
+Expected outcome:
+
+```
+Got it. I've added this task:
+ [D][ ][1] party (by: Sunday)
+```
+
+### `event` - creates an event task
+
+creates an event task which requires a time
+by which the event starts and a time by which
+the event ends, you will be subsequently
+prompted for prioritisation of the task
+
+Example of usage:
+
+`event hangout with Sara /from Mon 5pm /to Mon 10pm`
+
+(assume prioritisation is 1)
+
+Expected outcome:
+
+```
+Got it. I've added this task:
+ [E][ ][1] hangout with Sara (from: Mon 5pm to: Mon 10pm)"
+```
+
+### `find` - finds tasks related to a certain keyword
+
+finds and outputs tasks which pertain to the
+keyword inputted
+
+Example of usage:
+
+`find hangout`
+
+Expected outcome:
+
+```
+Here are the matching tasks in your list
+ [E][ ][1] hangout with Sara (from: Mon 5pm to: Mon 10pm)"
+```
+
+### `list` - lists all the tasks
+
+Example of usage:
+
+`list`
+
+Expected outcome:
+
+```
+Here are the tasks in your list
+ [T][ ][1] borrow book
+ [D][ ][1] party (by: Sunday)
+ [E][ ][1] hangout with Sara (from: Mon 5pm to: Mon 10pm)"
+```
+
+### `mark` - marks tasks
+
+use the mark command to mark tasks as completed, the mark command should be followed by
+an integer specifying the task which has been completed,
+using the list command in conjunction to find corresponding
+tasks is a good idea
+
+Example of usage:
+
+`mark 1`
+
+Expected outcome:
+
+```
+Marked Task: 'borrow book'
+```
+
+### `unmark` - unmarks tasks
+
+use the unmark command to mark tasks as uncompleted,
+the unmark command should be followed by an integer
+specifying the task which has not been completed,
+using the list command in conjunction to find
+corresponding tasks is a good idea
+
+Example of usage:
+
+`unmark 1`
Expected outcome:
-Description of the outcome.
+```
+Unmarked Task: 'borrow book'
+```
+
+### `delete` - deletes tasks
+
+use the delete command to delete tasks, be careful
+because once deleted, it cannot be brought back
+
+Example of usage:
+
+`delete 1`
+
+Expected outcome:
```
-expected output
+Deleted task: 'borrow book'
```
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..a2859e2078
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..d64cd49177
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..a80b22ce5c
--- /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-8.6-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..1aa94a4269
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,249 @@
+#!/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##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && 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=SC2039,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=SC2039,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, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+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..7101f8e467
--- /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. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
+
+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/charlie/commands/AddCommand.java b/src/main/java/charlie/commands/AddCommand.java
new file mode 100644
index 0000000000..3349773a9a
--- /dev/null
+++ b/src/main/java/charlie/commands/AddCommand.java
@@ -0,0 +1,109 @@
+package charlie.commands;
+
+import java.util.ArrayList;
+
+import charlie.exceptions.CharlieException;
+import charlie.models.Deadline;
+import charlie.models.Event;
+import charlie.models.Task;
+import charlie.models.Todo;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public class AddCommand extends Command {
+
+ private String fullCommand;
+ private String response;
+ private Integer priorityNumber;
+
+ /**
+ * constructor for AddCommand
+ * @param fullCommand the user command in its full string form
+ */
+ public AddCommand(String fullCommand, Integer priorityNumber) {
+ assert fullCommand != null && !fullCommand.trim().isEmpty() : "Full command must not be null or empty";
+ this.fullCommand = fullCommand;
+ this.priorityNumber = priorityNumber;
+ }
+
+ /**
+ * executes an add command, the method decides between tasks to-do, event and deadline, and
+ * saves the tasks to storage
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ * @throws CharlieException
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) throws CharlieException {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ if (fullCommand.startsWith("todo")) {
+ this.response = handleTodo(taskList.getTasks(), fullCommand);
+ } else if (fullCommand.startsWith("event")) {
+ this.response = handleEvent(taskList.getTasks(), fullCommand);
+ } else if (fullCommand.startsWith("deadline")) {
+ this.response = handleDeadline(taskList.getTasks(), fullCommand);
+ }
+ storage.saveTasks(taskList.getTasks());
+ isExit = false;
+ return this.response;
+ }
+
+ /**
+ * adds the to-do task to the current task list, and returns intended generated output
+ * @param taskList task list loaded at the start of the program.
+ * @param input to-do string which specifies the task saved
+ * @throws CharlieException
+ */
+ private String handleTodo(ArrayList taskList, String input) throws CharlieException {
+ assert input != null && !input.trim().equals("todo") : "Input for todo must not be empty";
+ if (input.trim().equals("todo")) {
+ throw new CharlieException("Sorry, the description of a todo cannot be empty.");
+ }
+ String description = input.substring(5);
+ Todo todo = new Todo(description, priorityNumber);
+ taskList.add(todo);
+ return generateResponse(todo, taskList.size());
+ }
+
+ /**
+ * adds the deadline task to the current task list, and returns intended generated output
+ * @param taskList task list loaded at the start of the program.
+ * @param input to-do string which specifies the task saved
+ * @throws CharlieException
+ */
+ private String handleDeadline(ArrayList taskList, String input) throws CharlieException {
+ assert input != null && input.trim().length() > 9 : "Input for deadline must be properly formatted";
+ String[] parts = input.substring(9).split(" /by ");
+ if (parts.length < 2 || parts[0].trim().isEmpty() || parts[1].trim().isEmpty()) {
+ throw new CharlieException("Sorry, the description of a deadline "
+ + "cannot be empty and must include a /by time.");
+ }
+ Deadline deadline = new Deadline(parts[0], priorityNumber, parts[1]);
+ taskList.add(deadline);
+ return generateResponse(deadline, taskList.size());
+ }
+
+ /**
+ * adds the event task to the current task list, and returns intended generated output
+ * @param taskList task list loaded at the start of the program.
+ * @param input to-do string which specifies the task saved
+ * @throws CharlieException
+ */
+ private String handleEvent(ArrayList taskList, String input) throws CharlieException {
+ assert input != null && input.trim().length() > 6 : "Input for event must be properly formatted";
+ String[] parts = input.substring(6).split(" /from ");
+ if (parts.length < 2 || parts[0].trim().isEmpty() || !parts[1].contains(" /to ")) {
+ throw new CharlieException("Sorry, the description of an event cannot be empty "
+ + "and must include start /from and /to end times.");
+ }
+ String[] timeParts = parts[1].split(" /to ");
+ Event event = new Event(parts[0], priorityNumber, timeParts[0], timeParts[1]);
+ taskList.add(event);
+ return generateResponse(event, taskList.size());
+ }
+
+ private String generateResponse(Task task, int size) {
+ return "Got it. I've added this task:\n " + task + "Now you have " + size + " tasks in the list.";
+ }
+
+}
diff --git a/src/main/java/charlie/commands/Command.java b/src/main/java/charlie/commands/Command.java
new file mode 100644
index 0000000000..5fd58b579e
--- /dev/null
+++ b/src/main/java/charlie/commands/Command.java
@@ -0,0 +1,27 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public abstract class Command {
+
+ protected boolean isExit;
+
+ /**
+ * Abstract execute method that aims to perform actions for a specific command.
+ * Needs to be overridden in sub-classes.
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ * @throws CharlieException
+ */
+ public abstract String execute(TaskList taskList, Storage storage) throws CharlieException;
+
+ /**
+ * getter method for the boolean value, which decides if the program exits or not, used in ExitCommand
+ * @return isExit
+ */
+ public boolean isExit() {
+ return isExit;
+ }
+}
diff --git a/src/main/java/charlie/commands/DeleteCommand.java b/src/main/java/charlie/commands/DeleteCommand.java
new file mode 100644
index 0000000000..5220ffdefb
--- /dev/null
+++ b/src/main/java/charlie/commands/DeleteCommand.java
@@ -0,0 +1,38 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.models.Task;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public class DeleteCommand extends Command {
+
+ private Integer index;
+
+ /**
+ * constructor for DeleteCommand
+ * @param index index of list item to be removed
+ */
+ public DeleteCommand(Integer index) {
+ assert index != null : "Task number to be deleted has to be specified";
+ this.index = index;
+ }
+
+ /**
+ * executes a delete command, the finds the task to be deleted within taskList, deletes the
+ * task and saves the new taskList to storage
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ * @throws CharlieException
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) throws CharlieException {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ Task taskToBeDeleted = taskList.getTasks().get(index - 1);
+ taskList.getTasks().remove(index - 1);
+ String response = "Deleted task: '" + taskToBeDeleted.getDescription();
+ storage.saveTasks(taskList.getTasks());
+ isExit = false;
+ return response;
+ }
+}
diff --git a/src/main/java/charlie/commands/ExitCommand.java b/src/main/java/charlie/commands/ExitCommand.java
new file mode 100644
index 0000000000..bb60fbe469
--- /dev/null
+++ b/src/main/java/charlie/commands/ExitCommand.java
@@ -0,0 +1,19 @@
+package charlie.commands;
+
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public class ExitCommand extends Command {
+
+ /**
+ * turns isExit to true, which effectively terminates the program
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ isExit = true;
+ return "See you later!";
+ }
+}
diff --git a/src/main/java/charlie/commands/FindCommand.java b/src/main/java/charlie/commands/FindCommand.java
new file mode 100644
index 0000000000..79ec36d628
--- /dev/null
+++ b/src/main/java/charlie/commands/FindCommand.java
@@ -0,0 +1,56 @@
+package charlie.commands;
+
+import java.util.ArrayList;
+
+import charlie.exceptions.CharlieException;
+import charlie.models.Task;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public class FindCommand extends Command {
+
+ private String keyword;
+
+ /**
+ * constructor for FindCommand
+ * @param keyword word to be searched in list of tasks
+ */
+ public FindCommand(String keyword) {
+ this.keyword = keyword;
+ }
+
+ /**
+ * executes a find command,
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ * @throws CharlieException
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) throws CharlieException {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ ArrayList tasks = taskList.getTasks();
+ ArrayList matchingTasks = findMatchingTasks(taskList.getTasks(), keyword);
+
+ if (matchingTasks.isEmpty()) {
+ String response = "No tasks found with the keyword: " + keyword;
+ return response;
+ } else {
+ StringBuilder responseBuild = new StringBuilder("Here are the matching tasks in your list:\n");
+ for (int i = 0; i < matchingTasks.size(); i++) {
+ Task task = matchingTasks.get(i);
+ responseBuild.append(i + 1).append(".").append(task).append("\n");
+ }
+ return responseBuild.toString();
+ }
+ }
+ private ArrayList findMatchingTasks(ArrayList tasks, String keyword) {
+ ArrayList matchingTasks = new ArrayList<>();
+ for (Task task : tasks) {
+ if (task.getDescription().contains(keyword)) {
+ matchingTasks.add(task);
+ }
+ }
+ return matchingTasks;
+ }
+
+}
diff --git a/src/main/java/charlie/commands/ListCommand.java b/src/main/java/charlie/commands/ListCommand.java
new file mode 100644
index 0000000000..4fde330dcc
--- /dev/null
+++ b/src/main/java/charlie/commands/ListCommand.java
@@ -0,0 +1,22 @@
+package charlie.commands;
+
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public class ListCommand extends Command {
+ /**
+ * executes the List command, which prints out all the tasks in taskList
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ StringBuilder responseBuild = new StringBuilder("Here are the tasks in your list:\n");
+ for (int i = 0; i < taskList.getTasks().size(); i++) {
+ responseBuild.append(i + 1).append(".").append(taskList.getTasks().get(i)).append("\n");
+ }
+ isExit = false;
+ return responseBuild.toString();
+ }
+}
diff --git a/src/main/java/charlie/commands/MarkCommand.java b/src/main/java/charlie/commands/MarkCommand.java
new file mode 100644
index 0000000000..a2a7002d76
--- /dev/null
+++ b/src/main/java/charlie/commands/MarkCommand.java
@@ -0,0 +1,39 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.models.Task;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+// unmark command
+
+public class MarkCommand extends Command {
+
+ private Integer index;
+
+ /**
+ * constructor for MarkCommand
+ * @param index index of list item to be marked or unmarked
+ */
+ public MarkCommand(Integer index) {
+ assert index != null : "Task number to be marked has to be specified";
+ this.index = index;
+ }
+
+ /**
+ * executes the mark command which effectively marks tasks as completed or uncompleted
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ * @throws CharlieException
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) throws CharlieException {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ Task taskToBeMarked = taskList.getTasks().get(index - 1);
+ taskToBeMarked.markAsDone();
+ String response = "Marked task: '" + taskToBeMarked.getDescription();
+ storage.saveTasks(taskList.getTasks());
+ isExit = false;
+ return response;
+ }
+}
diff --git a/src/main/java/charlie/commands/UnmarkCommand.java b/src/main/java/charlie/commands/UnmarkCommand.java
new file mode 100644
index 0000000000..0942efd203
--- /dev/null
+++ b/src/main/java/charlie/commands/UnmarkCommand.java
@@ -0,0 +1,39 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.models.Task;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+// unmark command
+
+public class UnmarkCommand extends Command {
+
+ private Integer index;
+
+ /**
+ * constructor for MarkCommand
+ * @param index index of list item to be marked or unmarked
+ */
+ public UnmarkCommand(Integer index) {
+ assert index != null : "Task number to be marked has to be specified";
+ this.index = index;
+ }
+
+ /**
+ * executes the mark command which effectively marks tasks as completed or uncompleted
+ * @param taskList - task list loaded at the start of the program.
+ * @param storage - class responsible for adding and loading tasks from and into the file
+ * @throws CharlieException
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) throws CharlieException {
+ assert taskList != null && storage != null : "TaskList and Storage must not be null";
+ Task taskToBeUnmarked = taskList.getTasks().get(index - 1);
+ taskToBeUnmarked.markAsNotDone();
+ String response = "Unmarked task: '" + taskToBeUnmarked.getDescription();
+ storage.saveTasks(taskList.getTasks());
+ isExit = false;
+ return response;
+ }
+}
diff --git a/src/main/java/charlie/exceptions/CharlieException.class b/src/main/java/charlie/exceptions/CharlieException.class
new file mode 100644
index 0000000000..0aff062e4f
Binary files /dev/null and b/src/main/java/charlie/exceptions/CharlieException.class differ
diff --git a/src/main/java/charlie/exceptions/CharlieException.java b/src/main/java/charlie/exceptions/CharlieException.java
new file mode 100644
index 0000000000..fe8c0c4c1e
--- /dev/null
+++ b/src/main/java/charlie/exceptions/CharlieException.java
@@ -0,0 +1,7 @@
+package charlie.exceptions;
+
+public class CharlieException extends Exception {
+ public CharlieException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/charlie/models/Deadline.class b/src/main/java/charlie/models/Deadline.class
new file mode 100644
index 0000000000..c61890e40f
Binary files /dev/null and b/src/main/java/charlie/models/Deadline.class differ
diff --git a/src/main/java/charlie/models/Deadline.java b/src/main/java/charlie/models/Deadline.java
new file mode 100644
index 0000000000..dd69425b4e
--- /dev/null
+++ b/src/main/java/charlie/models/Deadline.java
@@ -0,0 +1,51 @@
+package charlie.models;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+public class Deadline extends Task {
+ protected LocalDate by;
+ protected String byString;
+
+ /**
+ * constructor for task Deadline
+ * @param description description of task deadline in string form
+ * @param byString time by which the task deadline is due, is in ISO_LOCAL_DATE format (yyyy-MM-dd)
+ */
+ public Deadline(String description, Integer priorityNumber, String byString) {
+ super(description, priorityNumber);
+
+ // Assert that description is not null or empty
+ assert description != null && !description.trim().isEmpty() : "Description cannot be null or empty";
+ // Assert that byString is not null
+ assert byString != null : "byString cannot be null";
+ // handle the case where it's not a date
+
+ String datePattern = "\\d{4}-\\d{2}-\\d{2}";
+ if (byString.matches(datePattern)) {
+ this.by = LocalDate.parse(byString); // Assumes input is in ISO_LOCAL_DATE format (yyyy-MM-dd)
+ assert this.by != null : "Date parsing failed when it should have succeeded";
+ } else {
+ this.byString = byString;
+ }
+ }
+
+ /**
+ * @return description string for deadline event
+ */
+ @Override
+ public String toString() {
+ if (by != null) {
+ // `by` is set, so format it using DateTimeFormatter
+ return "[D]" + super.toString() + " (by: " + by.format(DateTimeFormatter.ofPattern("MMM d yyyy")) + ")";
+ } else {
+ // `by` is not set, meaning `byString` did not represent a date in the expected format
+ // In this case, simply return the `byString` without attempting to format it as a date
+ return "[D]" + super.toString() + " (by: " + byString + ")";
+ }
+ }
+ public String getBy() {
+ return this.byString;
+ }
+}
+
+
diff --git a/src/main/java/charlie/models/Event.class b/src/main/java/charlie/models/Event.class
new file mode 100644
index 0000000000..d34264d843
Binary files /dev/null and b/src/main/java/charlie/models/Event.class differ
diff --git a/src/main/java/charlie/models/Event.java b/src/main/java/charlie/models/Event.java
new file mode 100644
index 0000000000..28b8b46660
--- /dev/null
+++ b/src/main/java/charlie/models/Event.java
@@ -0,0 +1,41 @@
+package charlie.models;
+
+public class Event extends Task {
+ protected String startsAt;
+ protected String endsAt;
+
+ /**
+ * constructor for task Event
+ * @param description description of task Event in string form
+ * @param startsAt time by which the event starts
+ * @param endsAt time by which the event ends
+ */
+ public Event(String description, Integer priorityNumber,String startsAt, String endsAt) {
+ super(description, priorityNumber);
+
+ // Assert that description, startsAt, and endsAt are not null
+ assert description != null && !description.trim().isEmpty() : "Description cannot be null or empty";
+ assert startsAt != null && !startsAt.trim().isEmpty() : "Start time cannot be null or empty";
+ assert endsAt != null && !endsAt.trim().isEmpty() : "End time cannot be null or empty";
+
+ this.startsAt = startsAt;
+ this.endsAt = endsAt;
+ }
+
+ public String getStartsAt() {
+ return startsAt;
+ }
+
+ public String getEndsAt() {
+ return endsAt;
+ }
+
+ /**
+ * @return description string for task event
+ */
+ @Override
+ public String toString() {
+ return "[E]" + super.toString() + " (from: " + startsAt + " to: " + endsAt + ")";
+ }
+
+}
diff --git a/src/main/java/charlie/models/Task.class b/src/main/java/charlie/models/Task.class
new file mode 100644
index 0000000000..49399e818e
Binary files /dev/null and b/src/main/java/charlie/models/Task.class differ
diff --git a/src/main/java/charlie/models/Task.java b/src/main/java/charlie/models/Task.java
new file mode 100644
index 0000000000..10dc81510d
--- /dev/null
+++ b/src/main/java/charlie/models/Task.java
@@ -0,0 +1,69 @@
+package charlie.models;
+public class Task {
+ protected String description;
+ protected boolean isDone;
+ protected Integer priorityNumber;
+
+ /**
+ * constructor for tasks
+ * @param description contains information in the form of a string about the task
+ */
+ public Task(String description, Integer priorityNumber) {
+ assert description != null && !description.trim().isEmpty() : "Description cannot be null or empty";
+ this.description = description;
+ this.priorityNumber = priorityNumber;
+ this.isDone = false;
+ }
+
+ /**
+ * prints the current status of task
+ * @return the status of the task (whether it is completed or not
+ */
+ public String getStatusIcon() {
+ return (isDone ? "[X]" : "[ ]"); // mark done task with X
+ }
+
+ public Integer getPriority() {
+
+ return this.priorityNumber;
+ }
+
+ /**
+ * marks a task as done
+ */
+ public void markAsDone() {
+ isDone = true;
+ assert isDone : "Task should be marked as done";
+ }
+
+ /**
+ * marks a task as not done
+ */
+ public void markAsNotDone() {
+ isDone = false;
+ assert !isDone : "Task should be marked as not done";
+ }
+
+ /**
+ * @return whether or not the task has been successfully completed
+ */
+ public boolean isDone() {
+ return isDone;
+ }
+
+ /**
+ * @return the description of task
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @return returns the description of task and the status icon of
+ * whether or not it has been completed
+ */
+ @Override
+ public String toString() {
+ return getStatusIcon() + " [" + priorityNumber.toString() + "] " + description;
+ }
+}
diff --git a/src/main/java/charlie/models/Todo.class b/src/main/java/charlie/models/Todo.class
new file mode 100644
index 0000000000..c75632ac68
Binary files /dev/null and b/src/main/java/charlie/models/Todo.class differ
diff --git a/src/main/java/charlie/models/Todo.java b/src/main/java/charlie/models/Todo.java
new file mode 100644
index 0000000000..18dd79679b
--- /dev/null
+++ b/src/main/java/charlie/models/Todo.java
@@ -0,0 +1,15 @@
+package charlie.models;
+public class Todo extends Task {
+ public Todo(String description, Integer priorityNumber) {
+ super(description, priorityNumber);
+ assert description != null && !description.trim().isEmpty() : "Description cannot be null or empty";
+ }
+
+ /**
+ * @return string containing information about to-Do task
+ */
+ @Override
+ public String toString() {
+ return "[T]" + super.toString();
+ }
+}
diff --git a/src/main/java/charlie/parser/Parser.java b/src/main/java/charlie/parser/Parser.java
new file mode 100644
index 0000000000..74ef46d59c
--- /dev/null
+++ b/src/main/java/charlie/parser/Parser.java
@@ -0,0 +1,77 @@
+package charlie.parser;
+
+
+import charlie.commands.AddCommand;
+import charlie.commands.Command;
+import charlie.commands.DeleteCommand;
+import charlie.commands.ExitCommand;
+import charlie.commands.FindCommand;
+import charlie.commands.ListCommand;
+import charlie.commands.MarkCommand;
+import charlie.commands.UnmarkCommand;
+
+import charlie.exceptions.CharlieException;
+
+public class Parser {
+
+ public static Command parse(String fullCommand) throws CharlieException {
+ boolean addCommand = fullCommand.startsWith("todo") || fullCommand.startsWith("event")
+ || fullCommand.startsWith("deadline");
+ if (fullCommand.startsWith("delete")) {
+ return initiateDelete(fullCommand);
+ } else if (addCommand) {
+ return initiateAddCommand(fullCommand);
+ } else if (fullCommand.startsWith("list")) {
+ return initiateList();
+ } else if (fullCommand.startsWith("bye")) {
+ return initiateExit();
+ } else if (fullCommand.startsWith("mark")) {
+ return initiateMark(fullCommand);
+ } else if (fullCommand.startsWith("unmark")) {
+ return initiateUnmark(fullCommand);
+ } else if (fullCommand.startsWith("find")) {
+ return initiateFind(fullCommand);
+ } else {
+ throw new CharlieException("Sorry, unknown command, try again!");
+ }
+ }
+
+ private static Command initiateDelete(String fullCommand) throws CharlieException {
+ String[] words = fullCommand.split(" ");
+ assert words.length > 1 : "Delete command format is incorrect";
+ return new DeleteCommand(Integer.valueOf(words[1]));
+ }
+
+ private static Command initiateAddCommand(String fullCommand) {
+ String[] words = fullCommand.split(" ");
+ String priorityString = words[words.length-1];
+ Integer priorityNumber = Integer.parseInt(priorityString);
+ String actualCommand = fullCommand.substring(0, fullCommand.length()-2);
+ return new AddCommand(actualCommand, priorityNumber);
+ }
+ private static Command initiateList() {
+ return new ListCommand();
+ }
+
+ private static Command initiateExit() {
+ return new ExitCommand();
+ }
+
+ private static Command initiateMark(String fullCommand) throws CharlieException {
+ String[] words = fullCommand.split(" ");
+ assert words.length > 1 : "Mark command format is incorrect";
+ return new MarkCommand(Integer.valueOf(words[1]));
+ }
+
+ private static Command initiateUnmark(String fullCommand) throws CharlieException {
+ String[] words = fullCommand.split(" ");
+ assert words.length > 1 : "Unmark command format is incorrect";
+ return new UnmarkCommand(Integer.valueOf(words[1]));
+ }
+
+ private static Command initiateFind(String fullCommand) throws CharlieException {
+ String[] words = fullCommand.split(" ");
+ assert words.length > 1 : "Find command format is incorrect";
+ return new FindCommand(words[1]);
+ }
+}
diff --git a/src/main/java/charlie/storage/Storage.java b/src/main/java/charlie/storage/Storage.java
new file mode 100644
index 0000000000..21bf8d1777
--- /dev/null
+++ b/src/main/java/charlie/storage/Storage.java
@@ -0,0 +1,132 @@
+package charlie.storage;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+
+import charlie.exceptions.CharlieException;
+import charlie.models.Deadline;
+import charlie.models.Event;
+import charlie.models.Task;
+import charlie.models.Todo;
+
+public class Storage {
+
+ private String filePath;
+
+ /**
+ * creates a storage file (storage space) within which the list of tasks / user input can be saved
+ * @param filePath path within the current directory by which the storage file should be saved
+ */
+ public Storage(String filePath) {
+ assert filePath != null && !filePath.trim().isEmpty() : "filePath cannot be null or empty";
+ this.filePath = filePath;
+ }
+
+ /**
+ * loads tasks using the given filePath
+ * @return tasks loaded from the filePath
+ * @throws CharlieException
+ */
+ public ArrayList loadTasks() throws CharlieException {
+ ArrayList loadedTasks = new ArrayList<>();
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filePath));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ try {
+ loadedTasks.add(parseTaskFromFile(line));
+ } catch (IllegalArgumentException e) {
+ throw new CharlieException("Found a corrupted task in save file, skipping: " + line);
+ }
+ }
+ reader.close();
+ } catch (IOException e) {
+ throw new CharlieException("No saved tasks found, starting with an empty list.");
+ }
+ return loadedTasks;
+ }
+
+ /**
+ * The parseTaskFromFile method converts a single line of text into a specific Task object
+ * (to-Do, Deadline, or Event) based on the line's format, throwing an exception for unrecognized
+ * task types
+ * @param line line read from the storage file
+ * @return the task object
+ * @throws IllegalArgumentException
+ */
+ private Task parseTaskFromFile(String line) throws IllegalArgumentException {
+ String[] parts = line.split(" \\| ");
+ Task task = null;
+
+ switch (parts[0]) {
+ case "T":
+ task = new Todo(parts[3], Integer.parseInt(parts[2]));
+ break;
+ case "D":
+ task = new Deadline(parts[3], Integer.parseInt(parts[2]), parts[4]);
+ break;
+ case "E":
+ task = new Event(parts[3], Integer.parseInt(parts[2]), parts[4], parts[5]);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid task type in file.");
+ }
+
+ if (parts[1].equals("1")) {
+ task.markAsDone();
+ }
+ return task;
+ }
+
+ /**
+ * saves the list of tasks to the storage file
+ * @param taskList lists of tasks to be saved
+ * @throws CharlieException
+ */
+ public void saveTasks(ArrayList taskList) throws CharlieException {
+ try {
+ Files.createDirectories(Paths.get("./data"));
+ BufferedWriter writer = new BufferedWriter(new FileWriter(filePath));
+
+ for (Task task : taskList) {
+ writer.write(taskToFileFormat(task));
+ writer.newLine();
+ }
+
+ writer.close();
+ } catch (IOException e) {
+ throw new CharlieException("An error occurred while saving tasks to disk.");
+ }
+ }
+
+ /**
+ * converts tasks to format required to be written within files
+ * @param task task to be converted into format for saving within the file
+ * @return string of how the task should appear in file format
+ */
+ private String taskToFileFormat(Task task) {
+ String type = task instanceof Todo ? "T"
+ : task instanceof Deadline ? "D"
+ : task instanceof Event ? "E"
+ : "";
+ int done = task.isDone() ? 1 : 0;
+ int priority = task.getPriority();
+ String details = task.getDescription();
+
+ if (task instanceof Deadline) {
+ Deadline deadline = (Deadline) task;
+ details += " | " + deadline.getBy();
+ } else if (task instanceof Event) {
+ Event event = (Event) task;
+ details += " | " + event.getStartsAt() + " | " + event.getEndsAt();
+ }
+
+ return String.join(" | ", type, String.valueOf(done), String.valueOf(priority), details);
+ }
+}
diff --git a/src/main/java/charlie/storage/TaskList.java b/src/main/java/charlie/storage/TaskList.java
new file mode 100644
index 0000000000..c609e654e8
--- /dev/null
+++ b/src/main/java/charlie/storage/TaskList.java
@@ -0,0 +1,22 @@
+package charlie.storage;
+
+import charlie.models.Task;
+
+import java.util.ArrayList;
+
+public class TaskList {
+
+ private ArrayList tasks;
+
+ public TaskList(ArrayList tasks) {
+ this.tasks = tasks;
+ }
+
+ public TaskList() {
+ this.tasks = new ArrayList<>();
+ }
+
+ public ArrayList getTasks() {
+ return tasks;
+ }
+}
diff --git a/src/main/java/charlie/ui/Charlie.java b/src/main/java/charlie/ui/Charlie.java
new file mode 100644
index 0000000000..bc98633626
--- /dev/null
+++ b/src/main/java/charlie/ui/Charlie.java
@@ -0,0 +1,185 @@
+package charlie.ui;
+
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.ScrollPane;
+import javafx.scene.control.TextField;
+import javafx.scene.image.Image;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.Region;
+import javafx.scene.layout.VBox;
+import javafx.application.Application;
+import javafx.stage.Stage;
+
+import charlie.commands.Command;
+import charlie.exceptions.CharlieException;
+import charlie.parser.Parser;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+public class Charlie extends Application {
+
+ private Storage storage;
+ private TaskList tasks;
+ private String fullCommand;
+ private boolean priorityCommand = false;
+ private String priorityTaskCommand;
+ private Image user = new Image(this.getClass().getResourceAsStream("/images/User.png"));
+ private Image duke = new Image(this.getClass().getResourceAsStream("/images/Duke.png"));
+
+
+ private void initDuke(String filePath) {
+ try {
+ storage = new Storage(filePath);
+ tasks = new TaskList(storage.loadTasks());
+ } catch (CharlieException exception) {
+ exception.printStackTrace(); // Or handle it appropriately
+ tasks = new TaskList();
+ }
+ }
+
+ @Override
+ public void start(Stage stage) {
+ initDuke("./data/charlie.txt");
+ // Step 1. Setting up required components
+ ScrollPane scrollPane = new ScrollPane();
+ VBox dialogContainer = new VBox();
+ scrollPane.setContent(dialogContainer);
+
+ TextField userInput = new TextField();
+ Button sendButton = new Button("Send");
+
+ AnchorPane mainLayout = new AnchorPane();
+ mainLayout.getChildren().addAll(scrollPane, userInput, sendButton);
+
+ Scene scene = new Scene(mainLayout);
+ stage.setScene(scene);
+ stage.show();
+
+ stage.setTitle("charlie.ui.Duke");
+ 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) -> {
+ try {
+ handleUserInput(userInput, dialogContainer);
+ } catch (CharlieException e) {
+ System.out.println(e.getMessage());
+ }
+ });
+
+ userInput.setOnAction((event) -> {
+ try {
+ handleUserInput(userInput, dialogContainer);
+ } catch (CharlieException e) {
+ System.out.println(e.getMessage());
+ }
+ });
+
+ dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));
+ }
+ /**
+ * Iteration 1:
+ * Creates a label with the specified text and adds it to the dialog container.
+ * @param text String containing text to add
+ * @return a label with the specified text that has word wrap enabled.
+ */
+ private Label getDialogLabel(String text) {
+ // You will need to import `javafx.scene.control.Label`.
+ Label textToAdd = new Label(text);
+ textToAdd.setWrapText(true);
+ return textToAdd;
+ }
+
+ private void handleUserInput(TextField userInput, VBox dialogContainer) throws CharlieException {
+
+ String input = userInput.getText();
+ boolean isAddCommand = input.startsWith("todo") || input.startsWith("deadline")
+ || input.startsWith("event");
+
+ if (isAddCommand) {
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, user),
+ DialogBox.getDukeDialog("Assign this task a priority: ", duke)
+ );
+ setPriority(true,input);
+ userInput.clear();
+ } else if (this.priorityCommand & this.priorityTaskCommand != null) {
+ if (isNumeric(input)) {
+ String fullPriorityCommand = this.priorityTaskCommand + " " + input;
+ String response = "Assigned the task this priority " + input;
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, user),
+ DialogBox.getDukeDialog(response, duke),
+ DialogBox.getDukeDialog(getResponse(fullPriorityCommand), duke)
+ );
+ userInput.clear();
+ setPriority(false, null);
+ } else {
+ throw new CharlieException("Priority should be a number");
+ }
+ } else {
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, user),
+ DialogBox.getDukeDialog(getResponse(input), duke)
+ );
+ userInput.clear();
+ }
+ }
+
+ /**
+ * You should have your own function to generate a response to user input.
+ * Replace this stub with your completed method.
+ */
+ public String getResponse(String input) throws CharlieException {
+ String fullCommand = input;
+ try {
+ Command c = Parser.parse(fullCommand);
+ String response = c.execute(tasks, storage);
+ return response;
+ } catch (CharlieException e) {
+ return e.getMessage();
+ }
+ }
+ private void setPriority(boolean priorityCommand, String priorityTaskCommand) {
+ this.priorityCommand = priorityCommand;
+ this.priorityTaskCommand = priorityTaskCommand;
+ }
+
+ private static boolean isNumeric(String str) {
+ try {
+ Double.parseDouble(str);
+ return true;
+ } catch(NumberFormatException e){
+ return false;
+ }
+ }
+
+}
diff --git a/src/main/java/charlie/ui/DialogBox.java b/src/main/java/charlie/ui/DialogBox.java
new file mode 100644
index 0000000000..f8c0ce5bf3
--- /dev/null
+++ b/src/main/java/charlie/ui/DialogBox.java
@@ -0,0 +1,56 @@
+package charlie.ui;
+
+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;
+
+import java.io.IOException;
+import java.util.Collections;
+
+public class DialogBox extends HBox {
+
+ private Label text;
+
+ @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);
+ }
+
+ 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/charlie/ui/Launcher.java b/src/main/java/charlie/ui/Launcher.java
new file mode 100644
index 0000000000..9230cb29a7
--- /dev/null
+++ b/src/main/java/charlie/ui/Launcher.java
@@ -0,0 +1,13 @@
+package charlie.ui;
+
+import javafx.application.Application;
+
+/**
+ * A launcher class to workaround classpath issues.
+ */
+public class Launcher {
+
+ public static void main(String[] args) {
+ Application.launch(Charlie.class, args);
+ }
+}
diff --git a/src/main/java/charlie/ui/MainWindow.java b/src/main/java/charlie/ui/MainWindow.java
new file mode 100644
index 0000000000..caed2e3b67
--- /dev/null
+++ b/src/main/java/charlie/ui/MainWindow.java
@@ -0,0 +1,52 @@
+package charlie.ui;
+
+import charlie.exceptions.CharlieException;
+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 charlie.ui.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 Charlie duke;
+
+ private Image userImage = new Image(this.getClass().getResourceAsStream("/images/User.png"));
+ private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/charlie.ui.Duke.png"));
+
+ @FXML
+ public void initialize() {
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ }
+
+ public void setDuke(Charlie d) {
+ this.duke = d;
+ }
+
+ /**
+ * Creates two dialog boxes, one echoing user input and the other containing charlie.ui.Duke's reply and then appends them to
+ * the dialog container. Clears the user input after processing.
+ */
+ @FXML
+ private void handleUserInput() throws CharlieException {
+ 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/resources/images/duke.png b/src/main/resources/images/duke.png
new file mode 100644
index 0000000000..85d4186953
Binary files /dev/null and b/src/main/resources/images/duke.png differ
diff --git a/src/main/resources/images/user.png b/src/main/resources/images/user.png
new file mode 100644
index 0000000000..fdc1089f53
Binary files /dev/null and b/src/main/resources/images/user.png 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..fb7c516edf
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/charlie/commands/AddCommandTest.java b/src/test/java/charlie/commands/AddCommandTest.java
new file mode 100644
index 0000000000..666addf1c4
--- /dev/null
+++ b/src/test/java/charlie/commands/AddCommandTest.java
@@ -0,0 +1,76 @@
+package charlie.commands; //same package as the class being tested
+
+import charlie.models.*;
+import charlie.exceptions.CharlieException;
+import charlie.storage.Storage;
+import charlie.storage.TaskList;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class AddCommandTest {
+
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private Storage storage;
+
+ @BeforeEach
+ public void setUpStreams() {
+ System.setOut(new PrintStream(outContent));
+ }
+
+ @AfterEach
+ public void restoreStreams() {
+ System.setOut(originalOut);
+ }
+
+ @Test
+ public void testAddTodoTask() throws CharlieException {
+
+ Command command = new AddCommand("todo borrow book", 2);
+ Task todoTask = new Todo("todo borrow book", 3);
+ ArrayList tasks = new ArrayList<>();
+ tasks.add(todoTask);
+ TaskList tasklist = new TaskList(tasks);
+ storage = new Storage("./data/charlie.txt");
+ String response = command.execute(tasklist, storage);
+
+ String expectedResponse = "Got it. I've added this task:\n" +
+ " [T][ ] borrow book\n" +
+ "Now you have 1 tasks in the list.";
+
+ // Check if the actual response contains the expected text
+ assertTrue(response.contains("Got it. I've added this task:"));
+ assertTrue(response.contains("[T][ ] borrow book"));
+ assertTrue(response.contains("tasks in the list."));
+ }
+
+ @Test
+ public void testAddDeadlineTask() throws CharlieException {
+
+ Command command = new AddCommand("deadline return book /by 2019-10-15", 3);
+ Task deadlineTask = new Deadline("return book", 5, "2019-10-15");
+ ArrayList tasks = new ArrayList<>();
+ tasks.add(deadlineTask);
+ TaskList tasklist = new TaskList(tasks);
+ storage = new Storage("./data/charlie.txt");
+ String response = command.execute(tasklist, storage);
+
+ String expectedResponse = "Got it. I've added this task:\n" +
+ " [D][ ] return book (by: Oct 15 2019)\n" +
+ "Now you have 2 tasks in the list.";
+
+ // Check if the actual response contains the expected text
+ assertTrue(response.contains("Got it. I've added this task:"));
+ assertTrue(response.contains("[D][ ] return book (by: Oct 15 2019)"));
+ assertTrue(response.contains("tasks in the list."));
+ }
+
+}
diff --git a/src/test/java/charlie/commands/DeleteCommandTest.java b/src/test/java/charlie/commands/DeleteCommandTest.java
new file mode 100644
index 0000000000..aaa6f2ade1
--- /dev/null
+++ b/src/test/java/charlie/commands/DeleteCommandTest.java
@@ -0,0 +1,43 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.storage.*;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class DeleteCommandTest {
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private Storage storage;
+
+ @BeforeEach
+ public void setUpStreams() {
+ System.setOut(new PrintStream(outContent));
+ }
+
+ @AfterEach
+ public void restoreStreams() {
+ System.setOut(originalOut);
+ }
+
+ @Test
+ public void testDeleteTask() throws CharlieException {
+
+ Command command = new DeleteCommand(1);
+ storage = new Storage("./data/charlie.txt");
+ TaskList tasks = new TaskList(storage.loadTasks());
+ String response = command.execute(tasks, storage);
+
+ String expectedResponse = "Deleted task: 'todo borrow book'";
+
+ // Check if the actual response contains the expected text
+ assertTrue(response.contains("Deleted task:"));
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/charlie/commands/ExitCommandTest.java b/src/test/java/charlie/commands/ExitCommandTest.java
new file mode 100644
index 0000000000..c28d9e0e20
--- /dev/null
+++ b/src/test/java/charlie/commands/ExitCommandTest.java
@@ -0,0 +1,43 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.storage.*;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ExitCommandTest {
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private Storage storage;
+
+ @BeforeEach
+ public void setUpStreams() {
+ System.setOut(new PrintStream(outContent));
+ }
+
+ @AfterEach
+ public void restoreStreams() {
+ System.setOut(originalOut);
+ }
+
+ @Test
+ public void testDeleteTask() throws CharlieException {
+
+ Command command = new ExitCommand();
+ storage = new Storage("./data/charlie.txt");
+ TaskList tasks = new TaskList();
+ String response = command.execute(tasks, storage);
+
+ String expectedResponse = "See you later!";
+
+ // Check if the actual response contains the expected text
+ assertTrue(response.equals("See you later!"));
+ }
+
+}
\ No newline at end of file
diff --git a/src/test/java/charlie/commands/ListCommandTest.java b/src/test/java/charlie/commands/ListCommandTest.java
new file mode 100644
index 0000000000..5287ee2d87
--- /dev/null
+++ b/src/test/java/charlie/commands/ListCommandTest.java
@@ -0,0 +1,42 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.storage.*;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class ListCommandTest {
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private Storage storage;
+
+ @BeforeEach
+ public void setUpStreams() {
+ System.setOut(new PrintStream(outContent));
+ }
+
+ @AfterEach
+ public void restoreStreams() {
+ System.setOut(originalOut);
+ }
+
+ @Test
+ public void testDeleteTask() throws CharlieException {
+
+ Command command = new ListCommand();
+ storage = new Storage("./data/charlie.txt");
+ TaskList tasks = new TaskList(storage.loadTasks());
+ String response = command.execute(tasks, storage);
+ String expectedResponse = "Here are the tasks in your list:\n" +
+ "1.[T][ ] borrow book\n";
+
+ // Check if the actual response contains the expected text
+ assertTrue(response.contains("Here are the tasks in your list:\n"));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/charlie/commands/MarkCommandTest.java b/src/test/java/charlie/commands/MarkCommandTest.java
new file mode 100644
index 0000000000..94f19a9622
--- /dev/null
+++ b/src/test/java/charlie/commands/MarkCommandTest.java
@@ -0,0 +1,43 @@
+package charlie.commands;
+
+import charlie.exceptions.CharlieException;
+import charlie.storage.*;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class MarkCommandTest {
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private Storage storage;
+
+ @BeforeEach
+ public void setUpStreams() {
+ System.setOut(new PrintStream(outContent));
+ }
+
+ @AfterEach
+ public void restoreStreams() {
+ System.setOut(originalOut);
+ }
+
+ @Test
+ public void testMarkTask() throws CharlieException {
+
+ Command command = new MarkCommand(1);
+ storage = new Storage("./data/charlie.txt");
+ TaskList tasks = new TaskList(storage.loadTasks());
+ String response = command.execute(tasks, storage);
+
+ String expectedResponse = "Marked task: 'borrow book";
+
+ // Check if the actual response contains the expected text
+ assertTrue(response.contains("Marked task: "));
+ }
+
+}
\ No newline at end of file
diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT
index 657e74f6e7..d5f9d60b78 100644
--- a/text-ui-test/EXPECTED.TXT
+++ b/text-ui-test/EXPECTED.TXT
@@ -1,7 +1,13 @@
-Hello from
- ____ _
-| _ \ _ _| | _____
-| | | | | | | |/ / _ \
-| |_| | |_| | < __/
-|____/ \__,_|_|\_\___|
-
+Hello, I'm charlie
+What can I do for you?
+Got it. I've added this task:
+ [T][ ] borrow book
+Now you have 1 tasks in the list.
+Here are the tasks in your list:
+1.[T][ ] borrow book
+Got it. I've added this task:
+ [D][ ] return book (by: Sunday)
+Now you have 2 tasks in the list.
+Got it. I've added this task:
+ [E][ ] project meeting (from: Mon 2pm to: 4pm)
+Now you have 3 tasks in the list.
diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt
index e69de29bb2..4e4722e9c6 100644
--- a/text-ui-test/input.txt
+++ b/text-ui-test/input.txt
@@ -0,0 +1,4 @@
+todo borrow book
+list
+deadline return book /by Sunday
+event project meeting /from Mon 2pm /to 4pm
\ No newline at end of file
diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat
index 0873744649..ccce35fa80 100644
--- a/text-ui-test/runtest.bat
+++ b/text-ui-test/runtest.bat
@@ -14,8 +14,12 @@ IF ERRORLEVEL 1 (
)
REM no error here, errorlevel == 0
+<<<<<<< HEAD
REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
-java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
+=======
+REM run the program, feed charlie.commands from input.txt file and redirect the output to the ACTUAL.TXT
+>>>>>>> add-gradle-support
+java -classpath ..\bin charlie.ui.Charlie < input.txt > ACTUAL.TXT
REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT
diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh
old mode 100644
new mode 100755
index c9ec870033..ad8c2445e0
--- a/text-ui-test/runtest.sh
+++ b/text-ui-test/runtest.sh
@@ -19,8 +19,12 @@ then
exit 1
fi
+<<<<<<< HEAD
# run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
-java -classpath ../bin Duke < input.txt > ACTUAL.TXT
+=======
+# run the program, feed Charlie.commands from input.txt file and redirect the output to the ACTUAL.TXT
+>>>>>>> add-gradle-support
+java -classpath ../bin Charlie < input.txt > ACTUAL.TXT
# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT