diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2a28c11ad4
--- /dev/null
+++ b/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: trackie.ui.Trackie
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..70f1585a6a
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,57 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'com.github.johnrengelman.shadow' version '7.1.2'
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ String javaFxVersion = '17.0.7'
+
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
+ 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'
+}
+
+test {
+ useJUnitPlatform()
+
+ testLogging {
+ events "passed", "skipped", "failed"
+
+ showExceptions true
+ exceptionFormat "full"
+ showCauses true
+ showStackTraces true
+ showStandardStreams = false
+ }
+}
+
+mainClassName = 'trackie.ui.Launcher'
+
+application {
+ mainClass.set("trackie.ui.Launcher")
+}
+
+shadowJar {
+ archiveFileName = 'trackie.jar'
+}
+
+run{
+ standardInput = System.in
+ enableAssertions = true
+}
diff --git a/docs/README.md b/docs/README.md
index 47b9f984f7..6e0c22940a 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,30 +1,89 @@
-# Duke User Guide
+# Trackie User Guide
-// Update the title above to match the actual product name
-// Product screenshot goes here
+
-// Product intro goes here
-## Adding deadlines
+Introducing the Trackie Bot - Add different types of tasks and manage your tasks with ease!
-// Describe the action and its outcome.
+## Adding a todo task
+Todo tasks are tasks with just a description.
+Say, you wanted to add a todo task with the description "task1",
+here's how you would do it:\
+`t task1`
-// Give examples of usage
+The bot will return:
+> Added: task1
-Example: `keyword (optional arguments)`
+## Adding a deadline task
+Deadline tasks are tasks that come with a deadline.
+To add a deadline task, simply provide the description
+and the deadline as a date-time in "yyyymmdd hhmm" format.
-// A description of the expected outcome goes here
+For instance, let's say that you want to add the following deadline:
+- Description: finish assignment
+- Deadline: 26th September 2024, 2359
-```
-expected output
-```
+This is done by issuing the following command:\
+`d finish assignment /by 20240926 2359`
-## Feature ABC
+As a result, the bot will return:
+> Added: finish assignment (by: 26 Sep 2024, 11:59:00pm)
-// Feature details
+## Adding an event task
+Event tasks are tasks that have both a start and end time.
+To add an event task, simply provide the description, the start time and the end time.
+Both the start time and end time should be in the same date-time format as that of the
+deadline task.
+For instance, to add the following event:
+- Description: attend party
+- Start time: 19th August 2021, 1900
+- End time: 19th August 2021, 2300
-## Feature XYZ
+This is how it's done:\
+`e attend party /from 20210819 1900 /to 20210819 2300`
-// Feature details
\ No newline at end of file
+And this is what you'll get:
+> Added: attend party (from: 19 Aug 2021, 7:00:00pm to: 19 Aug 2021, 11:00:00pm)
+
+## Listing Tasks
+To see a list of all your tasks, simply type `ls`.
+
+This will yield you a list of all your tasks, for instance:
+> Here are your current tasks: 1. [D][ ] finish project (by: 10 Jul 2020, 7:00:00am) 2. [T][ ] walk the dog
+
+## Marking/Unmarking Tasks
+You can choose to mark/unmark tasks by typing "mark x" where x is the
+index of the task you want to mark/unmark **according to the list shown
+by the list command.**
+
+Examples:
+
+`mark 1`:
+> Gratz, you've completed: task 1
+
+`unmark 2`:
+> Aight, I've unmarked the following: another task
+
+
+## Deleting Tasks
+Simply type "rm" followed by the index of the task to delete said task.
+
+Example:
+
+`rm 2`:
+> Deleted: do my homework
+
+## Finding Tasks
+If you would like to find a task, simply use the `find` command as follows: `find task1`.
+
+All the tasks that have "task1" as a substring of their description will be included in the list of tasks found.
+For instance, "task1" and "sometask123" are both matching queries.
+
+The bot will return the number of relevant tasks found and list those tasks as follows:
+>2 matching task(s) found: task1 sometask123 (by: 1 Jan 2020, 12:00:00am)
+
+## Help page
+If you're unsure about the list of commands that are available, you can always
+type `help` to bring up the list of available commands.
diff --git a/docs/Ui.png b/docs/Ui.png
new file mode 100644
index 0000000000..ede9024eeb
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..033e24c4cd
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..66c01cfeba
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000000..fcb6fca147
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000000..6689b85bee
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,92 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%"=="" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/data.txt b/src/data.txt
new file mode 100644
index 0000000000..02f6c434cf
--- /dev/null
+++ b/src/data.txt
@@ -0,0 +1,3 @@
+T|0|walk my dog
+D|1|some assignment|20210909 2359
+D|0|submit quiz|20240925 2359
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/trackie/commands/AddCommand.java b/src/main/java/trackie/commands/AddCommand.java
new file mode 100644
index 0000000000..fe7bbc1a3a
--- /dev/null
+++ b/src/main/java/trackie/commands/AddCommand.java
@@ -0,0 +1,72 @@
+package trackie.commands;
+
+import java.time.format.DateTimeParseException;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.tasks.Deadline;
+import trackie.tasks.Event;
+import trackie.tasks.Task;
+import trackie.tasks.Todo;
+import trackie.ui.TrackieException;
+
+/**
+ * A command that adds a task to TaskList.
+ *
+ * The type of command that is added is determined by the
+ * arguments that are passed in.
+ */
+public class AddCommand extends Command {
+ private StringBuilder retriever = new StringBuilder();
+ private int ptr = 1;
+
+ /**
+ * Constructs a new Add Command with the arguments provided by the user.
+ *
+ * @param arguments An array of Strings storing the arguments provided by the user.
+ */
+ public AddCommand(String[] arguments) {
+ super.arguments = arguments;
+ }
+
+ /**
+ * Executes the add command.
+ * Depending on the first argument that the user provides, this command will
+ * tell the task list to add either a todo, deadline or event task.
+ * If an exception is thrown in the process of adding the command, its
+ * error message will be displayed to the user.
+ *
+ * @param taskList The TaskList object to which a task will be added.
+ * @param storage The Storage object used to save the updated task list.
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) throws TrackieException {
+ try {
+ switch (arguments[0]) {
+ case "t":
+ Task todoTask = new Todo(super.fetchDescription());
+ taskList.addTask(todoTask);
+ assert !taskList.isEmpty() : "A task should have been added, but taskList was empty.";
+ return "Added: " + todoTask.toString();
+ case "d":
+ Task deadlineTask = new Deadline(super.fetchDescription(), super.fetchDeadline());
+ taskList.addTask(deadlineTask);
+ assert !taskList.isEmpty() : "A task should have been added, but taskList was empty.";
+ return "Added: " + deadlineTask.toString();
+ case "e":
+ Task eventTask = new Event(super.fetchDescription(), super.fetchStartTime(), super.fetchEndTime());
+ taskList.addTask(eventTask);
+ assert !taskList.isEmpty() : "A task should have been added, but taskList was empty.";
+ return "Added: " + eventTask.toString();
+ default:
+ return "Invalid Command bro";
+ }
+ } catch (TrackieException e) {
+ return e.getMessage();
+ } catch (DateTimeParseException ex) {
+ return "Correct format for date and time: yyyyddmm hhmm\n" + "(Also make sure your dates are possible!)";
+ } finally {
+ storage.save();
+ }
+ }
+}
diff --git a/src/main/java/trackie/commands/Command.java b/src/main/java/trackie/commands/Command.java
new file mode 100644
index 0000000000..648048fba7
--- /dev/null
+++ b/src/main/java/trackie/commands/Command.java
@@ -0,0 +1,101 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.ui.TrackieException;
+
+/**
+ * Represents an abstract command in the task management application.
+ * This class serves as a base for all concrete command implementations.
+ */
+public abstract class Command {
+ protected String[] arguments;
+
+ public String[] getArguments() {
+ return this.arguments;
+ }
+
+ public String fetchDescription() throws TrackieException {
+
+ StringBuilder descFetcher = new StringBuilder();
+ int ptr = 1;
+ while (ptr < arguments.length) {
+ if (arguments[ptr].charAt(0) == '/') {
+ break;
+ }
+ descFetcher.append(arguments[ptr]).append(' ');
+ ptr++;
+ }
+ if (descFetcher.isEmpty()) {
+ throw new TrackieException("Description cannot by empty brudda.");
+ }
+ return descFetcher.substring(0, descFetcher.length() - 1);
+ }
+
+ public String fetchDeadline() throws TrackieException {
+ int ptr = 1;
+ int marker = arguments.length;
+ StringBuilder deadlineFetcher = new StringBuilder();
+ while (ptr < arguments.length) {
+ if (arguments[ptr].equals("/by")) {
+ marker = ptr;
+ }
+ if (ptr > marker) {
+ deadlineFetcher.append(arguments[ptr]).append(' ');
+ }
+ ptr++;
+ }
+ if (deadlineFetcher.isEmpty()) {
+ throw new TrackieException("Bro gimme a deadline man");
+ }
+ return deadlineFetcher.substring(0, deadlineFetcher.length() - 1);
+ }
+
+ public String fetchStartTime() throws TrackieException {
+ int ptr = 1;
+ int marker = arguments.length;
+ StringBuilder startTimeFetcher = new StringBuilder();
+ while (ptr < arguments.length) {
+ if (arguments[ptr].equals("/to")) {
+ break;
+ }
+ if (arguments[ptr].equals("/from")) {
+ marker = ptr;
+ }
+ if (ptr > marker) {
+ startTimeFetcher.append(arguments[ptr]).append(' ');
+ }
+ ptr++;
+ }
+ if (startTimeFetcher.isEmpty()) {
+ throw new TrackieException("Cmon gimme a start time");
+ }
+ return startTimeFetcher.substring(0, startTimeFetcher.length() - 1);
+ }
+
+ public String fetchEndTime() throws TrackieException {
+ int ptr = 1;
+ int marker = arguments.length;
+ StringBuilder endTimeFetcher = new StringBuilder();
+ while (ptr < arguments.length) {
+ if (arguments[ptr].equals("/to")) {
+ marker = ptr;
+ }
+ if (ptr > marker) {
+ endTimeFetcher.append(arguments[ptr]).append(' ');
+ }
+ ptr++;
+ }
+ if (endTimeFetcher.isEmpty()) {
+ throw new TrackieException("Cmon gimme an end time");
+ }
+ return endTimeFetcher.substring(0, endTimeFetcher.length() - 1);
+ }
+ /**
+ * Executes the command. This method must be implemented by concrete subclasses.
+ *
+ * @param tasklist the TaskList to operate on
+ * @param storage the storage system to interact with
+ */
+ public abstract String execute(TaskList tasklist, Storage storage) throws TrackieException;
+}
diff --git a/src/main/java/trackie/commands/DeleteCommand.java b/src/main/java/trackie/commands/DeleteCommand.java
new file mode 100644
index 0000000000..fa3fe6c034
--- /dev/null
+++ b/src/main/java/trackie/commands/DeleteCommand.java
@@ -0,0 +1,52 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.tasks.Task;
+import trackie.ui.TrackieException;
+
+/**
+ * Represents a command to delete a task.
+ */
+public class DeleteCommand extends Command {
+ /**
+ * Constructs a new DeleteCommand with the given arguments.
+ *
+ * @param arguments An array of Strings containing the command arguments.
+ * Typically, this would include the index of the task to be deleted.
+ */
+ public DeleteCommand(String[] arguments) {
+ super.arguments = arguments;
+ }
+
+ /**
+ * Executes the delete command.
+ * This method attempts to delete a task from the task list based on the provided arguments,
+ * saves the updated task list. If the index provided is invalid, an exception will be thrown
+ * and handled, causing an error message to be printed.
+ *
+ * @param tasklist The TaskList object from which a task will be deleted.
+ * @param storage The Storage object used to save the updated task list.
+ */
+ @Override
+ public String execute(TaskList tasklist, Storage storage) {
+ try {
+ if (arguments.length == 1) {
+ throw new TrackieException("Please specify an index to unmark!");
+ }
+
+ int number = Integer.parseInt(arguments[1]);
+
+ if (number < 1 || number > tasklist.size()) {
+ throw new TrackieException("Invalid index.");
+ }
+
+ Task target = tasklist.getTasks().get(number - 1);
+ tasklist.deleteTask(number - 1);
+ storage.save();
+ return "Deleted: " + target.toString();
+ } catch (TrackieException e) {
+ return e.getMessage();
+ }
+ }
+}
diff --git a/src/main/java/trackie/commands/FindCommand.java b/src/main/java/trackie/commands/FindCommand.java
new file mode 100644
index 0000000000..60d09ff974
--- /dev/null
+++ b/src/main/java/trackie/commands/FindCommand.java
@@ -0,0 +1,64 @@
+package trackie.commands;
+
+import java.util.ArrayList;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.tasks.Task;
+import trackie.ui.TrackieException;
+
+/**
+ * Represents a command to find relevant tasks based on a query String.
+ */
+public class FindCommand extends Command {
+ private String[] arguments;
+ private int ptr = 1;
+ private StringBuilder retriever = new StringBuilder();
+
+ public FindCommand(String[] arguments) {
+ this.arguments = arguments;
+ }
+
+ /**
+ * Executes the Find Command.
+ *
+ * @param tasklist the TaskList to operate on
+ * @param storage the storage system to interact with
+ * @return a String representation of all the commands that match the query.
+ */
+ @Override
+ public String execute(TaskList tasklist, Storage storage) {
+ try {
+ if (arguments.length == 1) {
+ throw new TrackieException("Please provide a valid query to find!");
+ }
+
+ if (tasklist.isEmpty()) {
+ throw new TrackieException("Nothing to find =/");
+ }
+
+ while (ptr < arguments.length) {
+ retriever.append(arguments[ptr]).append(" ");
+ ptr++;
+ }
+
+ String query = retriever.substring(0, retriever.length() - 1);
+
+ ArrayList results = tasklist.findTasks(query);
+ if (results.isEmpty()) {
+ return "No tasks matched your query.";
+ }
+
+ StringBuilder listOfMatchingTasks = new StringBuilder();
+ for (Task t : results) {
+ listOfMatchingTasks.append(t.toString()).append(System.lineSeparator());
+ }
+ return String.format("%d matching task(s) found:\n\n" +
+ listOfMatchingTasks.toString(), results.size());
+
+
+ } catch (TrackieException e) {
+ return e.getMessage();
+ }
+ }
+}
diff --git a/src/main/java/trackie/commands/HelpCommand.java b/src/main/java/trackie/commands/HelpCommand.java
new file mode 100644
index 0000000000..55bd261c4a
--- /dev/null
+++ b/src/main/java/trackie/commands/HelpCommand.java
@@ -0,0 +1,31 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+
+/**
+ * Represents a command to render assistance to the user, should they be confused.
+ */
+public class HelpCommand extends Command {
+ private String helpText = "List of available commands:\n" +
+ "t - add todo task\n" +
+ "d - add delete task\n" +
+ "e - add event task\n" +
+ "mark - mark task as completed\n" +
+ "unmark - mark task as NOT completed\n" +
+ "rm - delete task\n" +
+ "ls - list tasks\n" +
+ "help - display available commands\n";
+
+ /**
+ * Executes the help command, which displays a list of available commands.
+ *
+ * @param taskList the TaskList to operate on
+ * @param storage the storage system to interact with
+ * @return the help text specifying the supported commands
+ */
+ @Override
+ public String execute(TaskList taskList, Storage storage) {
+ return helpText;
+ }
+}
diff --git a/src/main/java/trackie/commands/InvalidCommand.java b/src/main/java/trackie/commands/InvalidCommand.java
new file mode 100644
index 0000000000..36e997c685
--- /dev/null
+++ b/src/main/java/trackie/commands/InvalidCommand.java
@@ -0,0 +1,21 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+
+/**
+ * Represents an invalid command. This is usually due to spelling errors during user input.
+ */
+public class InvalidCommand extends Command {
+ /**
+ * Executes the invalid command.
+ * Notifies the user that the command that they have typed in is invalid.
+ *
+ * @param tasklist The TaskList object used.
+ * @param storage The Storage object used.
+ */
+ @Override
+ public String execute(TaskList tasklist, Storage storage) {
+ return "Invalid command m8. Maybe try typing \"help\" to see the list of available commands...";
+ }
+}
diff --git a/src/main/java/trackie/commands/ListCommand.java b/src/main/java/trackie/commands/ListCommand.java
new file mode 100644
index 0000000000..037c8ca78f
--- /dev/null
+++ b/src/main/java/trackie/commands/ListCommand.java
@@ -0,0 +1,36 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.tasks.Task;
+import trackie.ui.TrackieException;
+
+/**
+ * Represents a command to list out all the tasks in the tasklist at a given point in time.
+ */
+public class ListCommand extends Command {
+ StringBuilder listOfTasks = new StringBuilder();
+
+ /**
+ * Executes the list command.
+ * This method causes the tasklist to list out all the tasks that are stored in it
+ * at the point in time.
+ *
+ * @param tasklist The TaskList object from which a task will be deleted.
+ * @param storage The Storage object used to save the updated task list.
+ */
+ @Override
+ public String execute(TaskList tasklist, Storage storage) throws TrackieException {
+ if (tasklist.isEmpty()) {
+ throw new TrackieException("Nothing to list here =/");
+ }
+
+ int index = 1;
+ for (Task t : tasklist.getTasks()) {
+ listOfTasks.append(String.format("%d. [%s][%s] %s", index, t.getTaskType(), t.getStatusIcon(), t.toString()));
+ listOfTasks.append(System.lineSeparator());
+ index++;
+ }
+ return "Here are your current tasks: \n" + listOfTasks.toString();
+ }
+}
diff --git a/src/main/java/trackie/commands/MarkCommand.java b/src/main/java/trackie/commands/MarkCommand.java
new file mode 100644
index 0000000000..b182f37d83
--- /dev/null
+++ b/src/main/java/trackie/commands/MarkCommand.java
@@ -0,0 +1,49 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.ui.TrackieException;
+
+/**
+ * Represents a command to mark a certain task a completed.
+ */
+public class MarkCommand extends Command {
+ /**
+ * Constructs a new MarkCommand with the given arguments.
+ *
+ * @param arguments An array of Strings containing the arguments from the user\.
+ * Typically, this would include the index of the task to be marked completed.
+ */
+ public MarkCommand(String[] arguments) {
+ super.arguments = arguments;
+ }
+
+ /**
+ * Executes the mark command.
+ * This method causes the tasklist to mark a task as completed.
+ * The user is then notified of the tasks' completion by the chatbot.
+ *
+ * @param tasklist The TaskList object from which a task will be marked.
+ * @param storage The Storage object used to save the updated task list.
+ */
+ @Override
+ public String execute(TaskList tasklist, Storage storage) throws TrackieException {
+ try {
+ if (arguments.length == 1) {
+ throw new TrackieException("Please specify an index to mark!");
+ }
+
+ int number = Integer.parseInt(arguments[1]);
+
+ if (number < 1 || number > tasklist.size()) {
+ throw new TrackieException("Invalid index.");
+ }
+
+ tasklist.markTask(number - 1);
+ storage.save();
+ return "Gratz, you've completed: " + tasklist.getTasks().get(number - 1).toString();
+ } catch (TrackieException e) {
+ return e.getMessage();
+ }
+ }
+}
diff --git a/src/main/java/trackie/commands/UnmarkCommand.java b/src/main/java/trackie/commands/UnmarkCommand.java
new file mode 100644
index 0000000000..e4cfd0a091
--- /dev/null
+++ b/src/main/java/trackie/commands/UnmarkCommand.java
@@ -0,0 +1,44 @@
+package trackie.commands;
+
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+import trackie.ui.TrackieException;
+
+public class UnmarkCommand extends Command {
+ /**
+ * Constructs an Unmark Command.
+ *
+ * @param arguments the array containing the arguments input by the user.
+ */
+ public UnmarkCommand(String[] arguments) {
+ super.arguments = arguments;
+ }
+ /**
+ * Executes the unmark command.
+ * This method will cause the tasklist to mark a task as not completed.
+ * The user will be informed of the task's new status, which would be changed to
+ * not completed after the unmarking operation.
+ *
+ * @param tasklist The TaskList object from which a task will be unmarked.
+ * @param storage The Storage object used to save the updated task list.
+ */
+ @Override
+ public String execute(TaskList tasklist, Storage storage) {
+ try {
+ if (arguments.length == 1) {
+ throw new TrackieException("Please specify an index to unmark!");
+ }
+
+ int number = Integer.parseInt(arguments[1]);
+
+ if (number < 1 || number > tasklist.size()) {
+ throw new TrackieException("Invalid index.");
+ }
+ tasklist.unmarkTask(number - 1);
+ storage.save();
+ return "Aight, I've unmarked the following: " + tasklist.getTasks().get(number - 1).toString();
+ } catch (TrackieException e) {
+ return e.getMessage();
+ }
+ }
+}
diff --git a/src/main/java/trackie/parsing/Parser.java b/src/main/java/trackie/parsing/Parser.java
new file mode 100644
index 0000000000..f8c1db561b
--- /dev/null
+++ b/src/main/java/trackie/parsing/Parser.java
@@ -0,0 +1,38 @@
+package trackie.parsing;
+
+import trackie.commands.*;
+
+/**
+ * Represents a parser that is used to determine which command to execute, based on the user input.
+ */
+public class Parser {
+ /**
+ * Parses the command given by the user and returns a corresponding command
+ * depending on the first argument that the user provides.
+ *
+ * @param input the input string provided by the user.
+ * @return a relevant command, or and invalid command in the default case.
+ */
+ public static Command parseCommand(String input) {
+ String[] arguments = input.split(" ");
+ switch (arguments[0]) {
+ case "t", "d", "e":
+ return new AddCommand(arguments);
+ case "mark":
+ return new MarkCommand(arguments);
+ case "unmark":
+ return new UnmarkCommand(arguments);
+ case "rm":
+ return new DeleteCommand(arguments);
+ case "find":
+ return new FindCommand(arguments);
+ case "ls":
+ return new ListCommand();
+ case "help":
+ return new HelpCommand();
+ default:
+ return new InvalidCommand();
+ }
+ }
+
+}
diff --git a/src/main/java/trackie/storage/Storage.java b/src/main/java/trackie/storage/Storage.java
new file mode 100644
index 0000000000..c8996dcb8e
--- /dev/null
+++ b/src/main/java/trackie/storage/Storage.java
@@ -0,0 +1,121 @@
+package trackie.storage;
+
+import trackie.parsing.Parser;
+import trackie.tasks.Deadline;
+import trackie.tasks.Event;
+import trackie.tasks.Task;
+import trackie.tasks.Todo;
+import trackie.ui.TrackieException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.PrintWriter;
+import java.util.Scanner;
+
+/**
+ * Represents a storage mechanism that can load data into tasklist and
+ * save data to the tasklist.
+ */
+public class Storage {
+ private TaskList taskList;
+ private File fPtr;
+
+ /**
+ * Constructs a new Storage object.
+ *
+ * @param dirpath The path where the storage file will be created or accessed.
+ * @param taskList The TaskList object to be associated with this storage.
+ */
+ public Storage(String dirpath, TaskList taskList) {
+ try {
+ String filename = "data.txt";
+ fPtr = new File(dirpath);
+ if (!fPtr.exists()) {
+ fPtr.mkdirs();
+ }
+ fPtr = new File(dirpath + File.separatorChar + filename);
+ fPtr.createNewFile();
+ } catch (IOException e) {
+ System.out.println("Error creating file =(");
+ }
+
+ this.taskList = taskList;
+ }
+
+ /**
+ * Loads task data from the storage file into memory.
+ * This method reads the file and populates the associated TaskList with the stored tasks.
+ * After loading, it displays the list of loaded tasks.
+ */
+ public String load() {
+ try {
+ Scanner sc = new Scanner(fPtr);
+ while (sc.hasNextLine()) {
+ String s = sc.nextLine();
+ String[] arguments = s.split("\\|");
+
+ // add tasks according to their types
+ if (arguments[0].equals("T")) {
+ taskList.tasks.add(new Todo(arguments[2], Integer.parseInt(arguments[1])));
+ } else if (arguments[0].equals("D")) {
+ taskList.tasks.add(new Deadline(arguments[2], arguments[3], Integer.parseInt(arguments[1])));
+ } else if (arguments[0].equals("E")) {
+ taskList.tasks.add(new Event(arguments[2], arguments[3], arguments[4], Integer.parseInt(arguments[1])));
+ }
+ }
+
+ if (taskList.isEmpty()) {
+ return "You currently have no tasks =)";
+ }
+
+ String loadedList = Parser.parseCommand("list").execute(taskList, this);
+ return "Here are your tasks: \n" + loadedList;
+
+ } catch (FileNotFoundException e) {
+ return "Error: File not found.";
+ } catch (TrackieException ex) {
+ return ex.getMessage();
+ }
+ }
+
+ /**
+ * Saves the current state of the TaskList to the storage file.
+ * This method writes all tasks from the TaskList to the file, overwriting any existing content.
+ * Each task is saved with its type, status, description, and any additional type-specific information.
+ */
+ public void save() {
+ try {
+ PrintWriter pw = new PrintWriter(fPtr);
+ pw.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+
+ for (Task x : taskList.tasks) {
+ String data = "";
+ int status = x.getStatusIcon().equals("X") ? 1 : 0;
+ if (x instanceof Todo) {
+ data = String.format("T|%d|%s", status, x.getDescription());
+ } else if (x instanceof Deadline) {
+ Deadline d = (Deadline) x;
+ data = String.format("D|%d|%s|%s", status, d.getDescription(), d.getDeadline());
+ } else if (x instanceof Event) {
+ Event e = (Event) x;
+ data = String.format("E|%d|%s|%s|%s", status, e.getDescription(), e.getStartTime(), e.getEndTime());
+ }
+
+ try {
+ FileWriter fw = new FileWriter(fPtr, true);
+ fw.write(data);
+ fw.write(System.lineSeparator());
+ fw.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/src/main/java/trackie/storage/TaskList.java b/src/main/java/trackie/storage/TaskList.java
new file mode 100644
index 0000000000..93c23a2475
--- /dev/null
+++ b/src/main/java/trackie/storage/TaskList.java
@@ -0,0 +1,88 @@
+package trackie.storage;
+
+import trackie.tasks.Task;
+import trackie.ui.TrackieException;
+
+import java.util.ArrayList;
+
+/**
+ * Represents a task list designed for Trackie.
+ * This class manages a collection of Tasks and provides methods to add, list, mark, unmark, and delete tasks.
+ */
+public class TaskList {
+ ArrayList tasks;
+
+ /**
+ * Constructs a new TaskList with an empty list of tasks.
+ */
+ public TaskList() {
+ tasks = new ArrayList<>();
+ }
+
+ /**
+ * Checks if the task list is empty.
+ *
+ * @return true if the task list contains no tasks, false otherwise.
+ */
+ public boolean isEmpty() {
+ return tasks.isEmpty();
+ }
+
+ public ArrayList getTasks() {
+ return this.tasks;
+ }
+
+ public int size() {
+ return tasks.size();
+ }
+
+ /**
+ * Adds a task to the tasklist.
+ */
+ public void addTask(Task task) {
+ tasks.add(task);
+ }
+
+ /**
+ * Marks a task as completed.
+ */
+ public void markTask(int index) {
+ tasks.get(index).markDone();
+ }
+
+ /**
+ * Marks a task as not completed.
+ */
+ public void unmarkTask(int index) {
+ tasks.get(index).markUndone();
+ }
+
+ /**
+ * Deletes a task from the task list.
+ */
+ public void deleteTask(int index) {
+ tasks.remove(index);
+ }
+
+ /**
+ * Searches for task(s) whose descriptions contain the specified query string.
+ *
+ * Note that the query string just has to be a substring of the task's description
+ * for the task to fulfil the query.
+ *
+ * @param query The search string to match against task descriptions.
+ * @return An ArrayList of Task objects whose descriptions contain the query string.
+ * @throws TrackieException If an error occurs during the search process.
+ */
+ public ArrayList findTasks(String query) throws TrackieException {
+ ArrayList tasksMatchingQuery = new ArrayList<>();
+ int noOfTasksFound = 0;
+ for (Task t : tasks) {
+ if (t.getDescription().contains(query)) {
+ tasksMatchingQuery.add(t);
+ noOfTasksFound++;
+ }
+ }
+ return tasksMatchingQuery;
+ }
+}
diff --git a/src/main/java/trackie/tasks/Deadline.java b/src/main/java/trackie/tasks/Deadline.java
new file mode 100644
index 0000000000..0eb6325f4c
--- /dev/null
+++ b/src/main/java/trackie/tasks/Deadline.java
@@ -0,0 +1,72 @@
+package trackie.tasks;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
+
+/**
+ * Represents a class of the type "Deadline".
+ */
+public class Deadline extends Task {
+ private String type = "D";
+ private String dateTimePattern = "yyyyMMdd HHmm";
+
+ private LocalDateTime deadline;
+
+ private DateTimeFormatter parsingFormatter = DateTimeFormatter.ofPattern(dateTimePattern);
+ private DateTimeFormatter readingFormatter = DateTimeFormatter.ofLocalizedDateTime(
+ FormatStyle.MEDIUM,
+ FormatStyle.MEDIUM
+ );
+
+ /**
+ * Creates a deadline task.
+ *
+ * @param description the description of the deadline task.
+ * @param deadline the deadline of the task, given in yyyy-mm-dd format.
+ */
+ public Deadline(String description, String deadline) {
+ super(description);
+ this.deadline = LocalDateTime.parse(deadline, parsingFormatter);
+ }
+
+ /**
+ * Creates a deadline task with a custom completion status.
+ *
+ * @param description the description of the deadline task.
+ * @param deadline the deadline of the task, given in yyyy-mm-dd.
+ * @param status the completion of the status of the task.
+ */
+ public Deadline(String description, String deadline, int status) {
+ super(description, status);
+ this.deadline = LocalDateTime.parse(deadline, parsingFormatter);
+ }
+
+ /**
+ * Retrieves relevant information about the task.
+ *
+ * @return A String containing the description and the deadline of the task.
+ */
+ @Override
+ public String toString() {
+ return(String.format("%s (by: %s)", super.description, this.deadline.format(readingFormatter)));
+ }
+
+ /**
+ * Retrieves the type of the task.
+ *
+ * @return A String denoting the type of the task. In this case, the type is "D".
+ */
+ public String getTaskType() {
+ return(this.type);
+ }
+
+ /**
+ * Retrieves the deadline of the task.
+ *
+ * @return A String representation of the deadline of the task, in yyyy-mm-dd.
+ */
+ public String getDeadline() {
+ return this.deadline.format(parsingFormatter);
+ }
+}
diff --git a/src/main/java/trackie/tasks/Event.java b/src/main/java/trackie/tasks/Event.java
new file mode 100644
index 0000000000..e6a7aa96a9
--- /dev/null
+++ b/src/main/java/trackie/tasks/Event.java
@@ -0,0 +1,82 @@
+package trackie.tasks;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.FormatStyle;
+
+/**
+ * Represents a task with type "Event".
+ */
+public class Event extends Task {
+ private String type = "E";
+ private String dateTimePattern = "yyyyMMdd HHmm";
+
+ private LocalDateTime startTime;
+ private LocalDateTime endTime;
+
+ private DateTimeFormatter parsingFormatter = DateTimeFormatter.ofPattern(dateTimePattern);
+ private DateTimeFormatter readingFormatter = DateTimeFormatter.ofLocalizedDateTime(
+ FormatStyle.MEDIUM,
+ FormatStyle.MEDIUM
+ );
+
+ /**
+ * Constructor to create an event task.
+ *
+ * @param description the description of the task.
+ * @param startString the start time of the task, as a string.
+ * @param endString the end time of the task, as a string.
+ */
+ public Event(String description, String startString, String endString) {
+ super(description);
+ this.startTime = LocalDateTime.parse(startString, parsingFormatter);
+ this.endTime = LocalDateTime.parse(endString, parsingFormatter);
+ }
+
+ /**
+ * Creates an event task with a custom completion status.
+ *
+ * @param description the description of the task.
+ * @param startString the start time of the task.
+ * @param endString the end time of the task.
+ * @param status the completion of the status of the task.
+ */
+ public Event(String description, String startString, String endString, int status) {
+ super(description, status);
+ this.startTime = LocalDateTime.parse(startString, parsingFormatter);
+ this.endTime = LocalDateTime.parse(endString, parsingFormatter);
+ }
+
+ /**
+ * Retrieves relevant information about the task.
+ *
+ * @return A String containing the description, the start time and the end time of the task.
+ */
+ public String toString() {
+ return(String.format("%s, (from: %s to: %s)", super.description,
+ this.startTime.format(readingFormatter),
+ this.endTime.format(readingFormatter)));
+ }
+
+ /**
+ * Retrieves the type of the task.
+ * @return A String denoting the type of the task. In this case, the type is "E".
+ */
+ public String getTaskType() {
+ return(this.type);
+ }
+
+ /**
+ * Retrieves the start time of the task.
+ *
+ * @return A String denoting the start time of the task.
+ */
+ public String getStartTime() { return this.startTime.format(parsingFormatter); }
+
+ /**
+ * Retrieves the end time of the task.
+ *
+ * @return A String denoting the end time of the task.
+ */
+ public String getEndTime() { return this.endTime.format(parsingFormatter); }
+}
diff --git a/src/main/java/trackie/tasks/Task.java b/src/main/java/trackie/tasks/Task.java
new file mode 100644
index 0000000000..820d725852
--- /dev/null
+++ b/src/main/java/trackie/tasks/Task.java
@@ -0,0 +1,84 @@
+package trackie.tasks;
+
+/**
+ * Represents an abstract task.
+ */
+public abstract class Task {
+ protected String description;
+ protected boolean isCompleted;
+
+ /**
+ * Creates a task.
+ *
+ * @param description the description supplied by the user.
+ */
+ public Task(String description) {
+ this.description = description;
+ this.isCompleted = false;
+ }
+
+ /**
+ * Creates a task with the specified completion status.
+ *
+ * @param description the description supplied by the user.
+ * @param status the completion status.
+ */
+ public Task(String description, int status) {
+ this.description = description;
+ if (status == 1) {
+ this.isCompleted = true;
+ } else {
+ this.isCompleted = false;
+ }
+ }
+
+ /**
+ * Generates the status icon for the task, depending on the completion status.
+ *
+ * @return "X" if completed, " " if not completed.
+ */
+ public String getStatusIcon() {
+ return isCompleted ? "X" : " ";
+ }
+
+ /**
+ * Retrieves the description of the task.
+ *
+ * @return A String containing the description of the task.
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Marks the task as completed.
+ */
+ public void markDone() {
+ this.isCompleted = true;
+ }
+
+ /**
+ * Marks the task as not completed.
+ */
+ public void markUndone() {
+ this.isCompleted = false;
+ }
+
+ /**
+ * Retrieves the relevant information about a task.
+ * This method must be implemented by subclasses.
+ *
+ * @return A String containing relevant information about the task,
+ * depending on the type of the task.
+ */
+ @Override
+ public abstract String toString();
+
+ /**
+ * Retrieves the type of the task.
+ * This method must be implemented by subclasses.
+ *
+ * @return A String denoting the type of the task.
+ */
+ public abstract String getTaskType();
+}
diff --git a/src/main/java/trackie/tasks/Todo.java b/src/main/java/trackie/tasks/Todo.java
new file mode 100644
index 0000000000..4cd34fe43d
--- /dev/null
+++ b/src/main/java/trackie/tasks/Todo.java
@@ -0,0 +1,47 @@
+package trackie.tasks;
+
+/**
+ * Represents a task of type "Todo".
+ */
+public class Todo extends Task {
+ private String type = "T";
+
+ /**
+ * Constructs a todo task.
+ *
+ * @param description the description of the task as supplied by the user.
+ */
+ public Todo(String description) {
+ super(description);
+ }
+
+ /**
+ * Constructs a todo task with a custom completion status.
+ *
+ * @param description the description fo the task as supplied by the user.
+ * @param status the completion status of the task.
+ */
+ public Todo(String description, int status) {
+ super(description, status);
+ }
+
+ /**
+ * Retrieves relevant information about the task.
+ *
+ * @return A String containing the description of the task.
+ */
+ @Override
+ public String toString() {
+ return(super.description);
+ }
+
+ /**
+ * Retrieves the type of the task.
+ *
+ * @return A String representing the type of the task. In this case, the type is "T".
+ */
+ @Override
+ public String getTaskType() {
+ return this.type;
+ }
+}
diff --git a/src/main/java/trackie/ui/DialogBox.java b/src/main/java/trackie/ui/DialogBox.java
new file mode 100644
index 0000000000..4c1686be55
--- /dev/null
+++ b/src/main/java/trackie/ui/DialogBox.java
@@ -0,0 +1,61 @@
+package trackie.ui;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
+import javafx.fxml.FXMLLoader;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.scene.control.Label;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.HBox;
+
+/**
+ * Represents a dialog box consisting of an ImageView to represent the speaker's face
+ * and a label containing text from the speaker.
+ */
+public class DialogBox extends HBox {
+ @FXML
+ private Label dialog;
+ @FXML
+ private ImageView displayPicture;
+
+ private DialogBox(String text, Image img) {
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader(MainWindow.class.getResource("/view/DialogBox.fxml"));
+ fxmlLoader.setController(this);
+ fxmlLoader.setRoot(this);
+ fxmlLoader.load();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ dialog.setText(text);
+ displayPicture.setImage(img);
+ }
+
+ /**
+ * Flips the dialog box such that the ImageView is on the left and text on the right.
+ */
+ private void flip() {
+ ObservableList tmp = FXCollections.observableArrayList(this.getChildren());
+ Collections.reverse(tmp);
+ getChildren().setAll(tmp);
+ setAlignment(Pos.TOP_LEFT);
+ dialog.getStyleClass().add("reply-label");
+ }
+
+ public static DialogBox getUserDialog(String text, Image img) {
+ return new DialogBox(text, img);
+ }
+
+ public static DialogBox getTrackieDialog(String text, Image img) {
+ var db = new DialogBox(text, img);
+ db.flip();
+ return db;
+ }
+}
diff --git a/src/main/java/trackie/ui/Launcher.java b/src/main/java/trackie/ui/Launcher.java
new file mode 100644
index 0000000000..aaa5ae012d
--- /dev/null
+++ b/src/main/java/trackie/ui/Launcher.java
@@ -0,0 +1,12 @@
+package trackie.ui;
+
+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/trackie/ui/Main.java b/src/main/java/trackie/ui/Main.java
new file mode 100644
index 0000000000..ba04deed3d
--- /dev/null
+++ b/src/main/java/trackie/ui/Main.java
@@ -0,0 +1,46 @@
+package trackie.ui;
+
+import java.io.IOException;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.ScrollPane;
+import javafx.scene.control.TextField;
+import javafx.scene.image.Image;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.VBox;
+import javafx.stage.Stage;
+
+
+
+public class Main extends Application {
+ private static final String DEFAULT_FILE_PATH = "src";
+ private Trackie trackie = new Trackie(DEFAULT_FILE_PATH);
+
+ public Main(String filepath) {
+ new Trackie(filepath);
+ }
+
+ // Overloaded constructor
+ public Main() {
+ this(DEFAULT_FILE_PATH);
+ }
+
+ @Override
+ public void start(Stage stage) {
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader(Main.class.getResource("/view/MainWindow.fxml"));
+ AnchorPane ap = fxmlLoader.load();
+ Scene scene = new Scene(ap);
+ stage.setScene(scene);
+ stage.setMinHeight(220);
+ stage.setMinWidth(417);
+ fxmlLoader.getController().setTrackie(trackie); // inject the Trackie instance
+ stage.show();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/trackie/ui/MainWindow.java b/src/main/java/trackie/ui/MainWindow.java
new file mode 100644
index 0000000000..c8bb060658
--- /dev/null
+++ b/src/main/java/trackie/ui/MainWindow.java
@@ -0,0 +1,59 @@
+package trackie.ui;
+
+import javafx.fxml.FXML;
+import javafx.scene.control.Button;
+import javafx.scene.control.ScrollPane;
+import javafx.scene.control.TextField;
+import javafx.scene.image.Image;
+import javafx.scene.layout.AnchorPane;
+import javafx.scene.layout.VBox;
+/**
+ * Controller for the main GUI.
+ */
+public class MainWindow extends AnchorPane {
+ @FXML
+ private ScrollPane scrollPane;
+ @FXML
+ private VBox dialogContainer;
+ @FXML
+ private TextField userInput;
+ @FXML
+ private Button sendButton;
+
+ private Trackie trackie;
+
+ private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.png"));
+ private Image trackieImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"));
+
+ @FXML
+ public void initialize() {
+ scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
+ greet();
+ }
+
+ /** Injects the Trackie instance */
+ public void setTrackie(Trackie t) {
+ trackie = t;
+ }
+
+ public void greet() {
+ dialogContainer.getChildren().addAll(
+ DialogBox.getTrackieDialog("Yo wassup! Trackie here =)",
+ new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"))));
+ }
+
+ /**
+ * 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 = trackie.getResponse(input);
+ dialogContainer.getChildren().addAll(
+ DialogBox.getUserDialog(input, userImage),
+ DialogBox.getTrackieDialog(response, trackieImage)
+ );
+ userInput.clear();
+ }
+}
diff --git a/src/main/java/trackie/ui/Trackie.java b/src/main/java/trackie/ui/Trackie.java
new file mode 100644
index 0000000000..8fd6ae0eb0
--- /dev/null
+++ b/src/main/java/trackie/ui/Trackie.java
@@ -0,0 +1,30 @@
+package trackie.ui;
+
+import javafx.scene.image.Image;
+import trackie.commands.Command;
+import trackie.parsing.Parser;
+import trackie.storage.Storage;
+import trackie.storage.TaskList;
+
+public class Trackie {
+ private Storage storage;
+ private TaskList tasks;
+
+ public Trackie(String filepath) {
+ tasks = new TaskList();
+ storage = new Storage(filepath, tasks);
+ storage.load();
+ }
+
+ /**
+ * Generates a response for the user's chat message.
+ */
+ public String getResponse(String input) {
+ try {
+ Command c = Parser.parseCommand(input);
+ return c.execute(this.tasks, this.storage);
+ } catch (TrackieException e) {
+ return e.getMessage();
+ }
+ }
+}
diff --git a/src/main/java/trackie/ui/TrackieException.java b/src/main/java/trackie/ui/TrackieException.java
new file mode 100644
index 0000000000..7671d26cf2
--- /dev/null
+++ b/src/main/java/trackie/ui/TrackieException.java
@@ -0,0 +1,7 @@
+package trackie.ui;
+
+public class TrackieException extends Exception {
+ public TrackieException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/resources/css/dialog-box.css b/src/main/resources/css/dialog-box.css
new file mode 100644
index 0000000000..065788c3a5
--- /dev/null
+++ b/src/main/resources/css/dialog-box.css
@@ -0,0 +1,25 @@
+.label {
+ -fx-background-color: linear-gradient(to bottom right, #ffd700, #01ffff);
+ -fx-border-color: #d55e00 #009e73 #cc79a7 #0072b2;
+ -fx-border-width: 2px;
+ -fx-background-radius: 1em 1em 0 1em;
+ -fx-border-radius: 1em 1em 0 1em;
+}
+
+.reply-label {
+ -fx-background-radius: 1em 1em 1em 0;
+ -fx-border-radius: 1em 1em 1em 0;
+}
+
+#displayPicture {
+ /* Shadow effect on image. */
+ -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.2), 10, 0.5, 5, 5);
+
+ /* Change size of image. */
+ -fx-scale-x: 1;
+ -fx-scale-y: 1;
+
+ /* Rotate image clockwise by degrees. */
+ -fx-rotate: 0;
+}
+
diff --git a/src/main/resources/css/main.css b/src/main/resources/css/main.css
new file mode 100644
index 0000000000..aa4f87b0a4
--- /dev/null
+++ b/src/main/resources/css/main.css
@@ -0,0 +1,47 @@
+.root {
+ main-color: rgb(237, 255, 242); /* Create a looked-up color called "main-color" within root. */
+ -fx-background-color: main-color;
+}
+
+.text-field {
+ -fx-background-color: #d9ffe2;
+ -fx-font: 18px "Arial";
+}
+
+.button {
+ -fx-background-color: linear-gradient(to bottom right, #01ffff, #ffd700);
+ -fx-font: italic bold 16px "Arial";
+}
+
+.button:hover {
+ -fx-background-color: linear-gradient(to bottom right, #01ffff, #ffd700);
+ -fx-font-size: 18px;
+}
+
+.button:pressed {
+ -fx-background-color: linear-gradient(to bottom left, #01ffff, #ffd700);
+ -fx-font-size: 20px;
+}
+
+.scroll-pane,
+.scroll-pane .viewport {
+ -fx-background-color: transparent;
+}
+
+.scroll-bar {
+ -fx-font-size: 10px; /* Change width of scroll bar. */
+ -fx-background-color: main-color;
+}
+
+.scroll-bar .thumb {
+ -fx-background-color: #ff9cb4;
+ -fx-background-radius: 1em;
+}
+
+/* Hides the increment and decrement buttons. */
+.scroll-bar .increment-button,
+.scroll-bar .decrement-button {
+ -fx-pref-height: 0;
+ -fx-opacity: 0;
+}
+
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..1a84e700ac
--- /dev/null
+++ b/src/main/resources/view/DialogBox.fxml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
new file mode 100644
index 0000000000..28cc71af3d
--- /dev/null
+++ b/src/main/resources/view/MainWindow.fxml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/test/java/trackie/parsing/ParserTest.java b/src/test/java/trackie/parsing/ParserTest.java
new file mode 100644
index 0000000000..48393800cb
--- /dev/null
+++ b/src/test/java/trackie/parsing/ParserTest.java
@@ -0,0 +1,27 @@
+package trackie.parsing;
+
+import org.junit.jupiter.api.Test;
+import trackie.commands.Command;
+import trackie.commands.InvalidCommand;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.time.format.DateTimeParseException;
+
+public class ParserTest {
+ @Test
+ public void testCommandParsing() {
+ String userInput = "lmao";
+ Command c = Parser.parseCommand(userInput);
+ assertEquals(c instanceof InvalidCommand, true);
+ }
+
+ @Test
+ public void testParsingResult() {
+ String userInput = "t ";
+ Command c = Parser.parseCommand(userInput);
+ assertEquals(c.getArguments().length, 1);
+ }
+}
diff --git a/src/test/java/trackie/storage/TaskListTest.java b/src/test/java/trackie/storage/TaskListTest.java
new file mode 100644
index 0000000000..1eff98e6f1
--- /dev/null
+++ b/src/test/java/trackie/storage/TaskListTest.java
@@ -0,0 +1,38 @@
+package trackie.storage;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+import trackie.tasks.Deadline;
+import trackie.tasks.Task;
+import trackie.tasks.Todo;
+
+public class TaskListTest {
+ @Test
+ public void testAddingCommands() {
+ TaskList tl = new TaskList();
+ tl.addTask(new Todo("hi lmao"));
+ tl.addTask(new Deadline("testing", "20200101 0000"));
+ assertEquals(tl.size(), 2);
+ }
+
+ @Test
+ public void testMarkingTasks() {
+ TaskList tl = new TaskList();
+ Task target = new Todo("hi lmao");
+ tl.addTask(target);
+ tl.markTask(0);
+ assertEquals("X", target.getStatusIcon());
+ }
+
+ @Test
+ public void testUnmarkingTasks() {
+ TaskList tl = new TaskList();
+ //Add a task with status initially set to completed
+ Task target = new Todo("hi lmao", 1);
+ tl.addTask(target);
+ tl.unmarkTask(0);
+ assertEquals(" ", target.getStatusIcon());
+ }
+}
diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT
index 657e74f6e7..2d94b6ac74 100644
--- a/text-ui-test/EXPECTED.TXT
+++ b/text-ui-test/EXPECTED.TXT
@@ -1,7 +1,29 @@
-Hello from
- ____ _
-| _ \ _ _| | _____
-| | | | | | | |/ / _ \
-| |_| | |_| | < __/
-|____/ \__,_|_|\_\___|
+Hello, I'm trackie.trackie. Nice to meet you =)
+Instructions:
+To add a todo task: todo [description]
+To add a deadline task: deadline [description] /by [deadline]
+To add an event task: event [description /from [start timing] /to [end timing]
+Type "list" to see the list of tasks
+Type "mark" or "unmark" followed by the task number to mark said task as done or undone.
+Type "bye" to exit.
+Type something: Added: [T][ ] something
+You now have 1 task(s) in total.
+Type something: Added: [D][ ] another thing (by: tonight)
+You now have 2 task(s) in total.
+Type something: Added: [E][ ] some other thing, (from: 11am to: 12pm)
+You now have 3 task(s) in total.
+Type something: 1. [T][ ] something
+2. [D][ ] another thing (by: tonight)
+3. [E][ ] some other thing, (from: 11am to: 12pm)
+Type something: Amazing! The specified task is now marked as complete:
+[X] another thing (by: tonight)
+Type something: Invalid index.
+Type something: Alright, the specified task has been marked undone:
+[ ] something
+Type something: Invalid index.
+Type something: Yes boss, I have removed the following task:
+[ ] something
+Type something: 1. [D][X] another thing (by: tonight)
+2. [E][ ] some other thing, (from: 11am to: 12pm)
+Type something: Seeya!
\ No newline at end of file
diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt
index e69de29bb2..4d64635ec7 100644
--- a/text-ui-test/input.txt
+++ b/text-ui-test/input.txt
@@ -0,0 +1,11 @@
+todo something
+deadline another thing /by tonight
+event some other thing /from 11am /to 12pm
+list
+mark 2
+mark 5
+unmark 1
+unmark 9
+delete 1
+list
+bye
\ No newline at end of file
diff --git a/text-ui-test/runtest.bat b/text-ui-test/runtest.bat
index 0873744649..184311d39b 100644
--- a/text-ui-test/runtest.bat
+++ b/text-ui-test/runtest.bat
@@ -15,7 +15,7 @@ IF ERRORLEVEL 1 (
REM no error here, errorlevel == 0
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
+java -classpath ..\bin trackie.trackie < 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..b802f80645
--- a/text-ui-test/runtest.sh
+++ b/text-ui-test/runtest.sh
@@ -20,7 +20,7 @@ then
fi
# 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
+java -classpath ../bin Trackie < input.txt > ACTUAL.TXT
# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT