diff --git a/.gitignore b/.gitignore
index 99712178bf..853c4c9a92 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,5 @@ src/main/resources/docs/
.DS_Store
*.iml
bin/
+# Duke generated files
+/savedTasks.txt
diff --git a/README.md b/README.md
index 84755485a7..13c5583700 100644
--- a/README.md
+++ b/README.md
@@ -22,11 +22,11 @@
# Tutorials
-Duke Increment | Tutorial
+TestDuke Increment | Tutorial
---------------|---------------
`A-Gradle` | [Gradle Tutorial](tutorials/gradleTutorial.md)
`A-TextUiTesting` | [Text UI Testing Tutorial](tutorials/textUiTestingTutorial.md)
-`Level-10` | JavaFX tutorials:
→ [Part 1: Introduction to JavaFX][fx1]
→ [Part 2: Creating a GUI for Duke][fx2]
→ [Part 3: Interacting with the user][fx3]
→ [Part 4: Introduction to FXML][fx4]
+`Level-10` | JavaFX tutorials:
→ [Part 1: Introduction to JavaFX][fx1]
→ [Part 2: Creating a GUI for TestDuke][fx2]
→ [Part 3: Interacting with the user][fx3]
→ [Part 4: Introduction to FXML][fx4]
[fx1]:
[fx2]:
diff --git a/_config.yml b/_config.yml
new file mode 100644
index 0000000000..c4192631f2
--- /dev/null
+++ b/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-cayman
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000000..57477697e1
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,39 @@
+plugins {
+ id 'java'
+ id 'application'
+ id 'checkstyle'
+ id 'com.github.johnrengelman.shadow' version '5.1.0'
+}
+
+dependencies {
+ testImplementation 'org.junit.jupiter:junit-jupiter:5.5.0'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.5.0'
+}
+test {
+ useJUnitPlatform()
+}
+checkstyle {
+ toolVersion = '8.23'
+}
+shadowJar {
+ archiveBaseName = "dukeIP"
+ archiveVersion = "0.1.4"
+ archiveClassifier = null
+ archiveAppendix = null
+}
+
+group 'seedu.duke'
+version '0.1.0'
+
+repositories {
+ mavenCentral()
+}
+
+application {
+ // Change this to your main class.
+ mainClassName = "Duke"
+}
+
+run {
+ standardInput = System.in
+}
\ No newline at end of file
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 0000000000..b1a57ba6c0
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,257 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/README.md b/docs/README.md
index fd44069597..84b20debd7 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,20 +1,106 @@
# User Guide
-## Features
-
-### Feature 1
-Description of feature.
+## Short introduction
+* Duke features adding of three types of task: `todo deadline event`.
+* Duke is also able to `delete` existing task, `find` specific task from a populated list of task and mark task as `done`.
+* In addition, Duke is able to convert user input description of `deadline` and `event` task if date-time is of the format `yyyy-mm-dd`
+## Features
+- [Features](#features)
+ - [Add a todo](#adding-a-task-todo)
+ - [Add a deadline](#adding-a-deadline-deadline)
+ - [Add an event](#adding-an-event-event)
+ - [List all tasks](#listing-all-tasks--list)
+ - [Mark task as complete](#marking-a-task-as-complete-done)
+ - [Delete a task](#deleting-a-task-delete)
+ - [Find a task](#locating-a-certain-task-find)
+ - [Exit Duke](#exiting-the-program-bye)
+ - [Save to hard disk](#saving-the-task-list)
+
## Usage
-### `Keyword` - Describe action
+### Adding a task: todo
+Adds a new task to Duke.
+Format: todo task
+Example of usage: todo CS2113T tutorial 5
+Expected outcome:
+```
+Got it . I've added this task:
+[T][✘] CS2113T tutorial 5
+Now you have x tasks in the list.
+```
+### Adding a deadline: deadline
+Adds a new task with deadline to Duke.
+Format: deadline task /by description of task
+Example of usage: deadline CS2113T tutorial 5 /by 2020-05-25 6.00pm
+Expected outcome:
+```
+Got it . I've added this task:
+[D][✘] CS2113T tutorial 5 (by: 5 MAY 2020, MONDAY 6.00pm)
+Now you have x tasks in the list.
+```
+### Adding an event: event
+Adds a new event task to Duke.
+Format: event task /at description
+Example of usage: event CS2113T oral presentation /at 2020-03-01 1.00pm
+Expected outcome:
+```
+Got it . I've added this task:
+[E][✘] CS2113T oral presentation (at: 3 MARCH 2020, SUNDAY 1.00pm)
+Now you have x tasks in the list.
+```
+### Listing all tasks : list
+Shows all the tasks user has typed into.
+Example of usage: list
+Expected outcome:
+```
+Here are the tasks in your list:
+1 .[T] Task 1
+2 .[D] Task 2
+```
+### Marking a task as complete: done
+Mark a specific task that user has typed in as completed.
+Format: done index
+Example of usage: done 1
+Expected outcome:
+```
+Nice! I've marked this task as done:
+[T] Task 1
+```
+* A tick[✔] will be shown instead of a cross[✘] to indicate task is completed.
+* index must be within the range of the displayed task list
+* index must start from 1
-Describe action and its outcome.
+### Deleting a task: delete
+Deletes a specific task from the list
of task.
+Format: delete index
+Example of usage: delete 1
+Expected outcome:
+```
+Noted, I've removed this task:
+[D] Task 1
+```
+* index must be within the range of the displayed task list
+* index must start from 1
-Example of usage:
+### Locating a certain task: find
+Find all the tasks which contains the keyword that user has typed in.
+Format: find keyword [more keyword]
+Example of usage: find CS2113T oral
+Expected outcome:
+```
+Here are the matching task/s in your list:
+[D] Task 1
+[T] Task 2
+```
+* Tasks containing at least one of the keyword would be displayed.
+* Order of keyword matters: find john roe
is not equivalent to find roe john
-`keyword (optional arguments)`
+### Exiting the program: bye
+Ends the Duke application.
+Example of usage: bye
-Expected outcome:
+### Saving the task list
+* Duke automatically saves the task list into your OS home directory under /savedTasks.txt
+* Duke automatically loads the task list from previous session if the file /savedTasks.txt
exist in your home directory.
-`outcome`
diff --git a/docs/_config.yml b/docs/_config.yml
new file mode 100644
index 0000000000..c4192631f2
--- /dev/null
+++ b/docs/_config.yml
@@ -0,0 +1 @@
+theme: jekyll-theme-cayman
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..87b738cbd0
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..ff73dca0fa
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Jan 21 23:15:28 SGT 2020
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStorePath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
new file mode 100755
index 0000000000..af6708ff22
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000000..6d57edc706
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem 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"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000000..d1e92fe5db
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'duke'
diff --git a/src/main/java/Duke.java b/src/main/java/Duke.java
index 5d313334cc..a5406a9bf9 100644
--- a/src/main/java/Duke.java
+++ b/src/main/java/Duke.java
@@ -1,10 +1,108 @@
+import Features.Task;
+import Exception.DukeException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Scanner;
+
+/**
+ * Main bot control class for users to manage their tasks.
+ * It includes features like setting deadlines, events and todos.
+ */
public class Duke {
+ private Storage myStorage;
+ private TaskList myTasks;
+ private UI myUI;
+
+ /**
+ * Initialise the required class instances.
+ * Loads the previous task list from file with Storage
object.
+ * @param f Location of the previously stored text file.
+ */
+ public Duke(File f) {
+ myUI = new UI();
+ myStorage = new Storage(f);
+ try {
+ myTasks = new TaskList(myStorage.loadFromFile());
+ } catch (IOException e) {
+ System.out.println(e);
+ }
+ }
+
+ /**
+ *
+ * @param keyword First keyword that user inputs into the CLI.
+ * @param userInput The whole sentence that user inputs.
+ * @throws DukeException If keyword is not regcognized.
+ */
+ private void botResponse(String keyword, String userInput) throws DukeException {
+ switch (keyword) {
+ case "list": myTasks.listCommand();
+ break;
+ case "delete":
+ myTasks.deleteCommand(userInput);
+ break;
+ case "done":
+ myTasks.doneCommand(userInput);
+ break;
+ case "todo":
+ myTasks.addCommand(userInput, "todo");
+ break;
+ case "event":
+ myTasks.addCommand(userInput, "event");
+ break;
+ case "deadline":
+ myTasks.addCommand(userInput, "deadline");
+ break;
+ case "find":
+ myTasks.findCommand(userInput);
+ break;
+ default:
+ throw new DukeException("Unknown command.");
+ }
+ }
+
+ /**
+ * Main bot loop, stops when user inputs keyword "bye".
+ */
+ public void run() {
+ myUI.intro();
+ Scanner in = new Scanner(System.in);
+ String userInput = in.nextLine();
+ ArrayList words = Parser.convertStringToArr(userInput, " ");
+ String keyword = words.get(0);
+ while (!keyword.equals("bye")) {
+ try {
+ botResponse(keyword, userInput);
+ } catch (DukeException e) {
+ UI.printLines();
+ System.out.println("OOPS!! " + e);
+ UI.printLines();
+ } finally {
+ userInput = in.nextLine();
+ words = Parser.convertStringToArr(userInput, " ");
+ keyword = words.get(0);
+ }
+ }
+ try {
+ ArrayList listToSave = myTasks.getUserList();
+ if (!listToSave.equals(myStorage.loadFromFile())) {
+ myStorage.saveToFile(listToSave);
+ }
+ } catch (IOException e) {
+ System.out.println(e);
+ }
+ myUI.exit();
+ }
+
public static void main(String[] args) {
- String logo = " ____ _ \n"
- + "| _ \\ _ _| | _____ \n"
- + "| | | | | | | |/ / _ \\\n"
- + "| |_| | |_| | < __/\n"
- + "|____/ \\__,_|_|\\_\\___|\n";
- System.out.println("Hello from\n" + logo);
+ java.util.Properties properties = System.getProperties();
+ String home = properties.get("user.home").toString();
+ // your file name
+ String fileName = "savedTasks.txt";
+
+ File dir = new File(home);
+ File f = new File(dir, fileName);
+ new Duke(f).run();
}
}
diff --git a/src/main/java/Exception/DukeException.java b/src/main/java/Exception/DukeException.java
new file mode 100644
index 0000000000..d309e151a8
--- /dev/null
+++ b/src/main/java/Exception/DukeException.java
@@ -0,0 +1,7 @@
+package Exception;
+
+public class DukeException extends Exception {
+ public DukeException(String s) {
+ super(s);
+ }
+}
diff --git a/src/main/java/Features/Deadline.java b/src/main/java/Features/Deadline.java
new file mode 100644
index 0000000000..03343bc461
--- /dev/null
+++ b/src/main/java/Features/Deadline.java
@@ -0,0 +1,25 @@
+package Features;
+
+import java.time.LocalDate;
+
+/**
+ * Extension of Task
class specifying an Deadline
task.
+ */
+public class Deadline extends Task{
+ public Deadline(String description, String userDate) {
+ super(description);
+ this.dateToCompleteString = userDate;
+ }
+ public Deadline(String description, LocalDate userDate, String userTime) {
+ super(description);
+ this.timeToComplete = userTime;
+ this.dateToCompleteLocalDate = userDate;
+ }
+ public String getType() {
+ return "Deadline";
+ }
+ @Override
+ public String toString() {
+ return "[D]" + super.toString() + " (by: " + this.getTimeToComplete() + ")";
+ }
+}
diff --git a/src/main/java/Features/Event.java b/src/main/java/Features/Event.java
new file mode 100644
index 0000000000..03e2c7e1d4
--- /dev/null
+++ b/src/main/java/Features/Event.java
@@ -0,0 +1,26 @@
+package Features;
+
+import java.time.LocalDate;
+
+/**
+ * Extension of Task
class specifying an Event
task.
+ */
+public class Event extends Task{
+ public Event(String description, String userDate) {
+ super(description);
+ this.dateToCompleteString = userDate;
+ }
+ public Event(String description, LocalDate userDate, String userTime) {
+ super(description);
+ this.dateToCompleteLocalDate = userDate;
+ this.timeToComplete = userTime;
+ }
+
+ public String getType() {
+ return "Event";
+ }
+ @Override
+ public String toString() {
+ return "[E]" + super.toString() + " (at: " + this.getTimeToComplete() + ")";
+ }
+}
diff --git a/src/main/java/Features/Task.java b/src/main/java/Features/Task.java
new file mode 100644
index 0000000000..44bbf89dee
--- /dev/null
+++ b/src/main/java/Features/Task.java
@@ -0,0 +1,46 @@
+package Features;
+
+import java.time.LocalDate;
+
+/**
+ * Base class for the 3 specific task type: Event Deadline Todo
.
+ * Contain methods to check the elements of each task object.
+ */
+public abstract class Task {
+ protected String description;
+ protected boolean isDone;
+ protected String dateToCompleteString;
+ protected LocalDate dateToCompleteLocalDate;
+ protected String timeToComplete;
+
+ public Task(String description) {
+ this.description = description;
+ this.isDone = false;
+ dateToCompleteLocalDate = null;
+ dateToCompleteString = "";
+ timeToComplete = "";
+ }
+ public String getTimeToComplete() {
+ if (dateToCompleteLocalDate != null) {
+ return dateToCompleteLocalDate.getMonthValue() + " " + dateToCompleteLocalDate.getMonth() + " " +
+ dateToCompleteLocalDate.getYear() + ", " + dateToCompleteLocalDate.getDayOfWeek() + " " + timeToComplete;
+ } else {
+ return dateToCompleteString + " " + timeToComplete;
+ }
+ }
+ public String getStatusIcon() {
+ return (isDone ? "\u2713" : "\u2718"); //return tick or X symbols
+ }
+ public String getDescription() {
+ return this.description;
+ }
+ public String getType() {return "Task";}
+ public void setIsDone(boolean isDone) {
+ this.isDone = isDone;
+ }
+ public boolean getIsDone() {return isDone;}
+ @Override
+ public String toString() {
+ return "[" + this.getStatusIcon() + "] " + this.getDescription();
+ }
+}
diff --git a/src/main/java/Features/Todo.java b/src/main/java/Features/Todo.java
new file mode 100644
index 0000000000..e896374edd
--- /dev/null
+++ b/src/main/java/Features/Todo.java
@@ -0,0 +1,18 @@
+package Features;
+
+/**
+ * Extension of Task
class specifying an Todo
task.
+ */
+public class Todo extends Task {
+ public Todo(String description) {
+ super(description);
+ }
+
+ public String getType() {
+ return "Todo";
+ }
+ @Override
+ public String toString() {
+ return "[T]" + super.toString();
+ }
+}
diff --git a/src/main/java/Parser.java b/src/main/java/Parser.java
new file mode 100644
index 0000000000..bfcd2908c2
--- /dev/null
+++ b/src/main/java/Parser.java
@@ -0,0 +1,33 @@
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Contain methods that parses user input into java objects and vice versa.
+ */
+public class Parser {
+
+ public static ArrayList convertStringToArr(String userInput , String delimiter) {
+ return new ArrayList<>(Arrays.asList(userInput.split(delimiter)));
+ }
+ public static ArrayList convertStringToArr(String userInput, String delimiter, int arrSize) {
+ return new ArrayList<>(Arrays.asList(userInput.split(delimiter, arrSize)));
+ }
+
+ public static ArrayList descriptionFilter(int filterIndex, ArrayList userInputInArray) {
+ ArrayList toReturn = new ArrayList<>();
+ String description = "";
+ String furtherDescription = "";
+ for (int i=0; iArrayList of Task
object that is to be saved into the textfile.
+ * @throws IOException If file doesn't exist or corrupted.
+ */
+ public void saveToFile(ArrayList userList) throws IOException {
+ FileWriter fw = new FileWriter(f);
+ for (Task elem : userList) {
+ String toSave = elem.getType() + " , " + elem.getIsDone() + " , " + elem.getDescription();
+ if (!elem.getType().equals("Todo")) {
+ toSave = toSave + " , " + elem.getTimeToComplete();
+ }
+ fw.write(toSave + "\n");
+ }
+ fw.close();
+ }
+
+ /**
+ * Returns an ArrayList
of Task
previously stored in the textfile
+ * If textfile doesn't exist, returns a new ArrayList
of Task
instead.
+ * @return List of tasks user previously input.
+ * @throws IOException If textfile is unable to be created. For eg, no space in disk.
+ */
+ public ArrayList loadFromFile() throws IOException {
+ if (f.exists()) {
+ try {
+ return taskFromFile();
+ } catch (DukeException | FileNotFoundException e) {
+ System.out.println("OOPS! " + e);
+ }
+ } else {
+ f.createNewFile();
+ }
+ return new ArrayList<>();
+ }
+
+ /**
+ * Parses the file into an ArrayList
of Task
object and returns it.
+ * @return Returns the parsed task list.
+ * @throws DukeException If user edits the textfile such that the textfile is un-parseable by application.
+ * @throws FileNotFoundException If user deletes the textfile during runtime.
+ */
+ public ArrayList taskFromFile() throws DukeException, FileNotFoundException {
+ Scanner s = new Scanner(f);
+ ArrayList savedUserList = new ArrayList<>();
+ String currTaskString = ""; //Follows format: TASK | 1 | DESCRIPTION | TIME
+ while (s.hasNext()) {
+ currTaskString = s.nextLine();
+ ArrayList savedString = Parser.convertStringToArr(currTaskString, " , ");
+ ArrayList savedDescription = new ArrayList();
+ savedDescription.add(savedString.get(2));
+ Task taskToLoad;
+ switch(savedString.get(0)) {
+ case "Todo":
+ taskToLoad = TaskList.newTodo(savedDescription);
+ break;
+ case "Deadline":
+ savedDescription.add("/by");
+ savedDescription.add(savedString.get(3));
+ taskToLoad = TaskList.newDeadline(savedDescription);
+ break;
+ case "Event":
+ savedDescription.add("/at");
+ savedDescription.add(savedString.get(3));
+ taskToLoad = TaskList.newEvent(savedDescription);
+ break;
+ default:
+ throw new DukeException("File is corrupted. Unable to find task name.");
+ }
+ taskToLoad.setIsDone(Boolean.parseBoolean(savedString.get(1)));
+ savedUserList.add(taskToLoad);
+ }
+ return savedUserList;
+ }
+}
diff --git a/src/main/java/TaskList.java b/src/main/java/TaskList.java
new file mode 100644
index 0000000000..29e9e79a3f
--- /dev/null
+++ b/src/main/java/TaskList.java
@@ -0,0 +1,213 @@
+import Features.Deadline;
+import Features.Event;
+import Features.Task;
+import Features.Todo;
+import Exception.DukeException;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeParseException;
+import java.util.ArrayList;
+
+/**
+ * Contain the list of tasks added by user.
+ * Contain methods that edits the list of tasks and to add specific type of task depending on keyword by user.
+ */
+public class TaskList {
+ private ArrayList userList;
+
+ public TaskList(ArrayList savedList) {
+ this.userList = savedList;
+ }
+
+ public ArrayList getUserList() {
+ return this.userList;
+ }
+ /**
+ * Returns a new To-do task object.
+ * @param userInputInArray Sentence containing the keyword and description of the to-do that user had typed into CLI.
+ * @return A new Todo
object containing the description.
+ * @throws DukeException If user types in a blank description.
+ */
+ public static Todo newTodo(ArrayList userInputInArray) throws DukeException {
+ String task = String.join(" ", userInputInArray);
+ if (task.length() == 0) { // if user inputs nothing after to-do
+ throw new DukeException("Format error, please follow: todo ");
+ }
+ return new Todo (task);
+ }
+ /**
+ * Returns a new Event task object.
+ * @param userInputInArray Sentence containing the keyword and description of the event that user had typed into CLI.
+ * @return A new Event
object containing the description and datetime(if any).
+ * @throws DukeException If user did not follow the format required. For eg, missing "/at" keyword.
+ */
+ public static Event newEvent(ArrayList userInputInArray) throws DukeException {
+ int atIndex = userInputInArray.indexOf("/at");
+ if (atIndex == -1) {
+ throw new DukeException("Format error, please follow: event /at ." +
+ "\nFeature: you can use as \"yyyy-mm-dd hr:min\" and we can format it for you!");
+ }
+ ArrayList filterByArr = Parser.descriptionFilter(atIndex, userInputInArray);
+ String description = filterByArr.get(0);
+ String at = filterByArr.get(1);
+ ArrayList userInputDelimit = Parser.convertStringToArr(at, " ", 2);
+ LocalDate myDate;
+ String myTime = "";
+ try {
+ myDate = LocalDate.parse(userInputDelimit.get(0));
+ myTime = userInputDelimit.get(1);
+
+ } catch (DateTimeParseException e) {
+ return new Event(description, String.join(" ", userInputDelimit));
+ } catch (IndexOutOfBoundsException e) {
+ myDate = LocalDate.parse(userInputDelimit.get(0));
+ return new Event(description, myDate, myTime);
+ }
+ return new Event(description, myDate, myTime);
+ }
+
+ /** Returns a new Deadline task object.
+ * @param userInputInArray Sentence containing the keyword and description of the deadline that user had typed into CLI.
+ * @return A new Deadline
object containing the description and datetime(if any).
+ * @throws DukeException If user did not follow the format required. For eg, missing "/by" keyword.
+ */
+ public static Deadline newDeadline(ArrayList userInputInArray) throws DukeException {
+ int byIndex = userInputInArray.indexOf("/by");
+ if (byIndex == -1) {
+ throw new DukeException("Format error, please follow: deadline /by ." +
+ "\nFeature: you can use as \"yyyy-mm-dd hr:min\" and we can format it for you!");
+ }
+ ArrayList filterByArr = Parser.descriptionFilter(byIndex, userInputInArray);
+ String description = filterByArr.get(0);
+ String by = filterByArr.get(1);
+ ArrayList userInputDelimit = Parser.convertStringToArr(by, " ", 2);
+ LocalDate myDate;
+ String myTime = "";
+ try {
+ myDate = LocalDate.parse(userInputDelimit.get(0));
+ myTime = userInputDelimit.get(1);
+ } catch (DateTimeParseException e) {
+ return new Deadline(description, String.join(" ", userInputDelimit));
+ } catch (IndexOutOfBoundsException e) {
+ myDate = LocalDate.parse(userInputDelimit.get(0));
+ return new Deadline(description, myDate, myTime);
+ }
+ return new Deadline(description, myDate, myTime);
+ }
+
+ /**
+ * Adds one of the three task: Todo Event Deadline
.
+ * @param userInput Sentence that user typed into CLI.
+ * @param taskType Type of task in String
.
+ */
+ public void addCommand(String userInput, String taskType) {
+ UI.printLines();
+ ArrayList userInputInArr = Parser.convertStringToArr(userInput, " ");
+ userInputInArr.remove(0);
+ try {
+ switch (taskType) {
+ case "todo":
+ userList.add(newTodo(userInputInArr));
+ break;
+ case "event":
+ userList.add(newEvent(userInputInArr));
+ break;
+ case "deadline":
+ userList.add(newDeadline(userInputInArr));
+ break;
+ }
+ UI.printAddedInfo(this.userList);
+ } catch (DukeException e) {
+ System.out.println("OOPS!! " + e);
+ }
+ UI.printLines();
+ }
+
+ /**
+ * Deletes a specific task via index.
+ * @param userInput Sentence that user typed into CLI.
+ * @throws DukeException If user inputs an invalid task index. For eg, an out of bound index.
+ */
+ public void deleteCommand(String userInput) throws DukeException {
+ UI.printLines();
+ String[] words = userInput.split(" ");
+ if (words.length != 2) {
+ throw new DukeException("Format error, please follow: \"delete \"");
+ }
+ try {
+ Integer deleteIndex = Integer.parseInt((words[1]));
+ deleteIndex--; // decrement doneIndex from one-based indexing to zero-based indexing to access ArrayList using it
+ System.out.println("Noted, I've removed this task:\n" + userList.get(deleteIndex));
+ userList.remove(userList.get(deleteIndex));
+ } catch (IndexOutOfBoundsException e) {
+ System.out.println("OOPS!! Task number " + words[1] + " is not within your list. type \"list\" for more info.");
+ } catch (NumberFormatException e) {
+ System.out.println("OOPS!! " + words[1] + " is not a valid task number");
+ }
+ UI.printLines();
+ }
+
+ /**
+ * Print out all tasks and its corresponding isDone
and LocalDate
within the task list.
+ */
+ public void listCommand() {
+ UI.printLines();
+ if (userList.size() == 0) {
+ System.out.println("No items added!");
+ } else {
+ System.out.println("Here are the tasks in your list:");
+ }
+ for (int i=0; iDONE
+ * @param userInput Sentence that user typed into CLI.
+ * @throws DukeException If user inputs an invalid task index. For eg, an out of bound index.
+ */
+ public void doneCommand( String userInput) throws DukeException {
+ UI.printLines();
+ String[] words = userInput.split(" ");
+ if (words.length != 2) {
+ throw new DukeException("Format error, please follow: \"done \"");
+ }
+ try {
+ Integer doneIndex = Integer.parseInt((words[1]));
+ doneIndex--; // decrement doneIndex from one-based indexing to zero-based indexing to access ArrayList using it
+ userList.get(doneIndex).setIsDone(true);
+ System.out.println("Nice! I've marked this task as done:");
+ System.out.println(userList.get(doneIndex));
+ } catch (IndexOutOfBoundsException e) {
+ System.out.println("OOPS!! Task number " + words[1] + " is not within your list. type \"list\" for more info.");
+ } catch (NumberFormatException e) {
+ System.out.println("OOPS!! " + words[1] + " is not a valid task number");
+ }
+ UI.printLines();
+ }
+
+ /**
+ * finds similar word pattern in user's task list.
+ * @param userInput Sentence that user typed in.
+ */
+ public void findCommand(String userInput) {
+ UI.printLines();
+ ArrayList delimitBySpace = Parser.convertStringToArr(userInput, " ", 2);
+ int counter = 0;
+ System.out.println("Here are the matching task/s in your list:");
+ for (Task elem : userList) {
+ if (elem.getDescription().toLowerCase().contains(delimitBySpace.get(1).toLowerCase())) {
+ counter += 1;
+ System.out.println(counter + ". " + elem);
+ }
+ }
+ if (counter == 0) {
+ System.out.println("Nothing was found.");
+ }
+ UI.printLines();
+ }
+}
diff --git a/src/main/java/UI.java b/src/main/java/UI.java
new file mode 100644
index 0000000000..9e6d16c718
--- /dev/null
+++ b/src/main/java/UI.java
@@ -0,0 +1,26 @@
+import Features.Task;
+import java.util.ArrayList;
+
+/**
+ * Contain methods to beautify the output text in CLI.
+ */
+public class UI {
+ private static String lines = "____________________________________________________________\n";
+ public static void printAddedInfo(ArrayList userList) {
+ System.out.println("Got it . I've added this task:");
+ System.out.print(" ");
+ System.out.println(userList.get(userList.size()-1));
+ System.out.println("Now you have " + userList.size() + " tasks in the list.");
+ }
+
+ public void intro() {
+ String toPrint = lines + "Hello! I'm Duke\n" + "What can I do for you?\n" + lines;
+ System.out.print(toPrint);
+ }
+ public static void printLines() {
+ System.out.println(lines);
+ }
+ public void exit() {
+ System.out.print(lines + "Bye. Hope to see you again soon!\n" + lines);
+ }
+}
diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..d2ffd5b4d2
--- /dev/null
+++ b/src/main/resources/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: Duke
+
diff --git a/src/test/java/TestDuke.java b/src/test/java/TestDuke.java
new file mode 100644
index 0000000000..9f87629db1
--- /dev/null
+++ b/src/test/java/TestDuke.java
@@ -0,0 +1,13 @@
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TestDuke {
+ @Test
+ void myTest() {
+ Duke myDuke = new Duke();
+
+// assertEquals(81, Duke.multiply(9, 9), "9 x 9 is 81");
+
+ }
+}
diff --git a/tutorials/gradleTutorial.md b/tutorials/gradleTutorial.md
index 08292b118d..1f15816a48 100644
--- a/tutorials/gradleTutorial.md
+++ b/tutorials/gradleTutorial.md
@@ -30,10 +30,10 @@ As a developer, you write a _build file_ that describes the project. A build fil
git checkout master
git merge gradle
```
-1. Open the `build.gradle` file in an editor. Update the following code block to point to the main class (i.e., the one containing the `main` method) of your application. The code below assumes your main class is `seedu.duke.Duke`
+1. Open the `build.gradle` file in an editor. Update the following code block to point to the main class (i.e., the one containing the `main` method) of your application. The code below assumes your main class is `seedu.duke.TestDuke`
```groovy
application {
- mainClassName = "seedu.duke.Duke"
+ mainClassName = "seedu.duke.TestDuke"
}
```
1. To check if Gradle has been added to the project correctly, open a terminal window, navigate to the root directory of your project and run the command `gradlew run`. This should result in Gradle running the main method of your project.
@@ -146,7 +146,7 @@ By convention, java tests belong in `src/test/java` folder. Create a new `test/j
src
├─main
│ └─java
-│ └─seedu/duke/Duke.java
+│ └─seedu/duke/TestDuke.java
└─test
└─java
└─seedu/duke/DukeTest.java
diff --git a/tutorials/javaFxTutorialPart1.md b/tutorials/javaFxTutorialPart1.md
index 561daeca43..0ff7258285 100644
--- a/tutorials/javaFxTutorialPart1.md
+++ b/tutorials/javaFxTutorialPart1.md
@@ -27,24 +27,31 @@ A JavaFX application is like a play you are directing. Instead of creating props
Update your `build.gradle` to include the following lines:
```groovy
-plugins {
- id 'java'
- id 'org.openjfx.javafxplugin' version '0.0.7'
-}
-
repositories {
mavenCentral()
}
-javafx {
- version = "11.0.2"
- modules = [ 'javafx.controls', 'javafx.fxml' ]
+dependencies {
+ String javaFxVersion = '11'
+
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
+ implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
}
```
## Writing your first program
-As customary, let’s start off with a simple “Hello World” program. Modify your `Duke` class to extend `javafx.application.Application`. This requires you to override the `Application#start()` method and provide a concrete implementation. Notice that the method signature for `Application#start()` has a parameter `Stage`. This is the _primary stage_ that JavaFX provides.
+As customary, let’s start off with a simple “Hello World” program. Modify your `TestDuke` class to extend `javafx.application.Application`. This requires you to override the `Application#start()` method and provide a concrete implementation. Notice that the method signature for `Application#start()` has a parameter `Stage`. This is the _primary stage_ that JavaFX provides.
```java
import javafx.application.Application;
@@ -52,7 +59,7 @@ import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
-public class Duke extends Application {
+public class TestDuke extends Application {
// ...
@@ -80,7 +87,7 @@ import javafx.application.Application;
*/
public class Launcher {
public static void main(String[] args) {
- Application.launch(Duke.class, args);
+ Application.launch(TestDuke.class, args);
}
}
```
diff --git a/tutorials/javaFxTutorialPart2.md b/tutorials/javaFxTutorialPart2.md
index f24a0cd6ad..856be2b799 100644
--- a/tutorials/javaFxTutorialPart2.md
+++ b/tutorials/javaFxTutorialPart2.md
@@ -1,8 +1,8 @@
-# JavaFX Tutorial Part 2 - Creating a GUI for Duke
+# JavaFX Tutorial Part 2 - Creating a GUI for TestDuke
-In this tutorial, we will be creating a GUI for Duke from scratch based on the following mockup.
+In this tutorial, we will be creating a GUI for TestDuke from scratch based on the following mockup.
-![Mockup for Duke](assets/DukeMockup.png)
+![Mockup for TestDuke](assets/DukeMockup.png)
## JavaFX controls
@@ -34,7 +34,7 @@ But how do we get the exact layout we want in the UI? JavaFX provides that funct
One way to obtain the layout in the mockup is as follows.
-![Duke's layout](assets/DukeSceneGraph.png)
+![TestDuke's layout](assets/DukeSceneGraph.png)
To get that layout, we create a new `AnchorPane` and add our controls to it. Similarly, we create a new `VBox` to hold the contents of the `ScrollPane`. The code should look something like this:
@@ -49,7 +49,7 @@ import javafx.scene.layout.VBox;
import javafx.stage.Stage;
-public class Duke extends Application {
+public class TestDuke extends Application {
private ScrollPane scrollPane;
private VBox dialogContainer;
@@ -88,7 +88,7 @@ public class Duke extends Application {
Run the application and you should see something like this:
-![Duke's raw layout](assets/RawLayout.png)
+![TestDuke's raw layout](assets/RawLayout.png)
That is not what we were expecting, what did we forget to do?
@@ -106,7 +106,7 @@ Add the following code to the bottom of the `start` method. You'll have to add `
//...
//Step 2. Formatting the window to look as expected
- stage.setTitle("Duke");
+ stage.setTitle("TestDuke");
stage.setResizable(false);
stage.setMinHeight(600.0);
stage.setMinWidth(400.0);
@@ -141,7 +141,7 @@ Add the following code to the bottom of the `start` method. You'll have to add `
Run the application again. It should now look like this:
-![Duke's Final layout](assets/FinalLayout.png)
+![TestDuke's Final layout](assets/FinalLayout.png)
## Exercises
diff --git a/tutorials/javaFxTutorialPart3.md b/tutorials/javaFxTutorialPart3.md
index a9e1bdddd3..c1012ab4e6 100644
--- a/tutorials/javaFxTutorialPart3.md
+++ b/tutorials/javaFxTutorialPart3.md
@@ -8,7 +8,7 @@ Rather than to do everything in one try, let’s iterate and build up towards ou
JavaFX has an _event-driven architecture style_. As such, we programmatically define _handler_ methods to execute as a response to certain _events_. When an event is detected, JavaFX will call the respective handlers.
-For Duke, there are two events that we want to respond to, namely the user pressing `Enter` in the `TextField` and left-clicking the `Button`. These are the `onAction` event for the `TextField` and the `onMouseClicked` event for the `Button`.
+For TestDuke, there are two events that we want to respond to, namely the user pressing `Enter` in the `TextField` and left-clicking the `Button`. These are the `onAction` event for the `TextField` and the `onMouseClicked` event for the `Button`.
For now, let’s have the application add a new `Label` with the text from the `TextField`. Update the `Main` class as follows. You'll need to add an `import javafx.scene.control.Label;` too.
```java
@@ -103,7 +103,7 @@ import javafx.scene.image.ImageView;
```
Next, add two images to the `main/resources/images` folder.
-For this tutorial, we have two images `DaUser.png` and `DaDuke.png` to represent the user avatar and Duke's avatar respectively but you can use any image you want.
+For this tutorial, we have two images `DaUser.png` and `DaDuke.png` to represent the user avatar and TestDuke's avatar respectively but you can use any image you want.
Image|Filename
---|---
@@ -112,7 +112,7 @@ Image|Filename
```java
-public class Duke extends Application {
+public class TestDuke extends Application {
// ...
private Image user = new Image(this.getClass().getResourceAsStream("/images/DaUser.png"));
private Image duke = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"));
@@ -124,7 +124,7 @@ Add a new method to handle user input:
```java
/**
* Iteration 2:
- * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to
+ * Creates two dialog boxes, one echoing user input and the other containing TestDuke's reply and then appends them to
* the dialog container. Clears the user input after processing.
*/
private void handleUserInput() {
@@ -142,7 +142,7 @@ private void handleUserInput() {
* Replace this stub with your completed method.
*/
private String getResponse(String input) {
- return "Duke heard: " + input;
+ return "TestDuke heard: " + input;
}
```
@@ -170,7 +170,7 @@ Run the program and see how it works.
## Iteration 3 – Adding custom behavior to DialogBox
-One additional benefit of defining a custom control is that we can add behavior specific to our `DialogBox`. Let’s add a method to flip a dialog box such that the image on the left to differentiate between user input and Duke’s output.
+One additional benefit of defining a custom control is that we can add behavior specific to our `DialogBox`. Let’s add a method to flip a dialog box such that the image on the left to differentiate between user input and TestDuke’s output.
```java
/**
@@ -224,7 +224,7 @@ Run the application and play around with it.
![DialogBoxes Iteration 3](assets/DialogBoxesIteration3.png)
Congratulations!
-You have successfully implemented a fully functional GUI for Duke!
+You have successfully implemented a fully functional GUI for TestDuke!
## Exercises
diff --git a/tutorials/javaFxTutorialPart4.md b/tutorials/javaFxTutorialPart4.md
index 0e0ab280c4..d6f2211f95 100644
--- a/tutorials/javaFxTutorialPart4.md
+++ b/tutorials/javaFxTutorialPart4.md
@@ -29,7 +29,7 @@ FXML is a XML-based language that allows us to define our user interface. Proper
The FXML snippet define a TextField similar to the one that we programmatically defined previous in Tutorial 2. Notice how concise FXML is compared to the plain Java version.
-Let's return to Duke and convert it to use FXML instead.
+Let's return to TestDuke and convert it to use FXML instead.
# Rebuilding the Scene using FXML
@@ -101,7 +101,7 @@ We will get to that later.
## Using Controllers
-As part of the effort to separate the code handling Duke's logic and UI, let's _refactor_ the UI-related code to its own class.
+As part of the effort to separate the code handling TestDuke's logic and UI, let's _refactor_ the UI-related code to its own class.
We call these UI classes _controllers_.
Let's implement the `MainWindow` controller class that we specified in `MainWindow.fxml`.
@@ -128,7 +128,7 @@ public class MainWindow extends AnchorPane {
@FXML
private Button sendButton;
- private Duke duke;
+ private TestDuke duke;
private Image userImage = new Image(this.getClass().getResourceAsStream("/images/DaUser.png"));
private Image dukeImage = new Image(this.getClass().getResourceAsStream("/images/DaDuke.png"));
@@ -138,12 +138,12 @@ public class MainWindow extends AnchorPane {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
}
- public void setDuke(Duke d) {
+ public void setDuke(TestDuke d) {
duke = d;
}
/**
- * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to
+ * Creates two dialog boxes, one echoing user input and the other containing TestDuke's reply and then appends them to
* the dialog container. Clears the user input after processing.
*/
@FXML
@@ -168,7 +168,7 @@ Similarly, methods like private methods like `handleUserInput` can be used in FX
## Using FXML in our application
-Let's create a new `Main` class as the bridge between the existing logic in `Duke` and the UI in `MainWindow`.
+Let's create a new `Main` class as the bridge between the existing logic in `TestDuke` and the UI in `MainWindow`.
**Main.java**
```java
@@ -182,11 +182,11 @@ import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
/**
- * A GUI for Duke using FXML.
+ * A GUI for TestDuke using FXML.
*/
public class Main extends Application {
- private Duke duke = new Duke();
+ private TestDuke duke = new TestDuke();
@Override
public void start(Stage stage) {
diff --git a/tutorials/textUiTestingTutorial.md b/tutorials/textUiTestingTutorial.md
index f397d76aef..ee0a18a477 100644
--- a/tutorials/textUiTestingTutorial.md
+++ b/tutorials/textUiTestingTutorial.md
@@ -13,7 +13,7 @@
del ACTUAL.TXT
REM compile the code into the bin folder
- javac -cp ..\src -Xlint:none -d ..\bin ..\src\main\java\Duke.java
+ javac -cp ..\src -Xlint:none -d ..\bin ..\src\main\java\TestDuke.java
IF ERRORLEVEL 1 (
echo ********** BUILD FAILURE **********
exit /b 1
@@ -21,7 +21,7 @@
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 TestDuke < input.txt > ACTUAL.TXT
REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT
@@ -44,14 +44,14 @@
fi
# compile the code into the bin folder, terminates if error occurred
- if ! javac -cp ../src -Xlint:none -d ../bin ../src/main/java/Duke.java
+ if ! javac -cp ../src -Xlint:none -d ../bin ../src/main/java/TestDuke.java
then
echo "********** BUILD FAILURE **********"
exit 1
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 TestDuke < input.txt > ACTUAL.TXT
# compare the output to the expected output
diff ACTUAL.TXT EXPECTED.TXT