Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tham You Wei] iP #536

Open
wants to merge 76 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
28ad2b8
Add Gradle support
May 24, 2020
ed6d4d2
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
eb4d5ff
Added Rename, Greet, Exit
tyouwei Aug 20, 2023
efc93d5
Added Echo
tyouwei Aug 20, 2023
e4b6b1b
Added Add, List
tyouwei Aug 20, 2023
8d6ed52
Added Mark as Done
tyouwei Aug 20, 2023
0d0a528
Added ToDos, Events, Deadlines
tyouwei Aug 20, 2023
5b3dc87
Added Automated text UI testing and fixed some input bugs
tyouwei Aug 21, 2023
03baad6
Added error handles
tyouwei Aug 21, 2023
8c2b377
Added delete
tyouwei Aug 21, 2023
76606d4
Use Enums
tyouwei Aug 21, 2023
c47583d
Add Save
tyouwei Aug 27, 2023
6e93a9d
Organise packages
tyouwei Aug 27, 2023
6fe56b1
Add Date Time
tyouwei Aug 27, 2023
012cb35
Chatbot revamp
tyouwei Aug 27, 2023
0d7c4e4
Chatbot revamp
tyouwei Aug 27, 2023
55a8bc4
Add Time
tyouwei Aug 27, 2023
2dffb61
More OOP
tyouwei Aug 28, 2023
35c2a83
package and cleanup
tyouwei Aug 28, 2023
6e0c07c
Merge branch 'branch-level-7' into add-gradle-support
tyouwei Aug 28, 2023
3c6d112
Use Gradle
tyouwei Aug 28, 2023
9e7638d
JUnit
tyouwei Aug 28, 2023
4af0479
Fix Bug
tyouwei Aug 28, 2023
98caa89
Delete faulty test
tyouwei Aug 28, 2023
a0fb381
More bug fixes
tyouwei Aug 28, 2023
908f26b
Add Javadocs
tyouwei Aug 28, 2023
5f71000
Coding Standard
tyouwei Aug 29, 2023
3b03c4d
Add Find
tyouwei Aug 29, 2023
b721849
gitignore
tyouwei Aug 29, 2023
09432be
gitignore
tyouwei Aug 29, 2023
57b6cbe
Command bug fix
tyouwei Aug 29, 2023
27d3b04
add checkstyles
tyouwei Sep 4, 2023
02dd638
Add GUI
tyouwei Sep 6, 2023
19f01f9
Add GUI
tyouwei Sep 6, 2023
153d38a
Merge branch 'branch-level-10'
tyouwei Sep 6, 2023
45d6430
checkstyles
tyouwei Sep 6, 2023
9184794
Add assertions
tyouwei Sep 10, 2023
85d575c
A-CodeQuality
tyouwei Sep 11, 2023
f9619a0
A-FullCommitMessage
tyouwei Sep 14, 2023
e2478e3
Bug Fix
tyouwei Sep 15, 2023
dabc291
Friendlier Syntax
tyouwei Sep 15, 2023
07cb0af
Test PR merge
tyouwei Sep 15, 2023
8ca7dd6
Merge pull request #1 from tyouwei/newbranch
tyouwei Sep 15, 2023
639cd72
Testing PR
tyouwei Sep 15, 2023
a922856
Testing PR
tyouwei Sep 15, 2023
fe38395
Merge branch 'master' into branch-A-Assertions
tyouwei Sep 15, 2023
11982c6
Merge pull request #3 from tyouwei/branch-A-Assertions
tyouwei Sep 15, 2023
8695ebd
Merge pull request #2 from tyouwei/branch-A-CodeQuality
tyouwei Sep 15, 2023
0aa9359
Add files via upload
tyouwei Sep 20, 2023
0c2b0ac
Update README.md
tyouwei Sep 20, 2023
f9de87d
Update README.md
tyouwei Sep 20, 2023
bf2ca21
Update README.md
tyouwei Sep 20, 2023
b877e86
Update README.md
tyouwei Sep 20, 2023
73de36f
Update README.md
tyouwei Sep 20, 2023
7c9ae33
Update README.md
tyouwei Sep 20, 2023
1d6de56
Update README.md
tyouwei Sep 20, 2023
6e574d1
Update README.md
tyouwei Sep 20, 2023
6dd1632
Update README.md
tyouwei Sep 20, 2023
60afd4d
Update README.md
tyouwei Sep 20, 2023
afef86d
Update README.md
tyouwei Sep 20, 2023
f7881e2
Update README.md
tyouwei Sep 20, 2023
4297325
Update README.md
tyouwei Sep 20, 2023
e1dc4f7
Update README.md
tyouwei Sep 20, 2023
fbd0925
Update README.md
tyouwei Sep 20, 2023
f11ef0c
Update README.md
tyouwei Sep 20, 2023
c2f7e73
Update README.md
tyouwei Sep 20, 2023
7526208
A-UserGuide
tyouwei Sep 20, 2023
fe161ec
A-UserGuide
tyouwei Sep 20, 2023
2421a59
A-UserGuide
tyouwei Sep 21, 2023
98e3ab9
README
tyouwei Sep 21, 2023
9ae52e6
Updated main README
tyouwei Sep 21, 2023
95306aa
Changed save file location
tyouwei Sep 21, 2023
cbe2819
More JUnit Testing
tyouwei Sep 21, 2023
f6410b4
Add images
tyouwei Sep 21, 2023
5921207
Update Ui.png
tyouwei Sep 21, 2023
b24e418
Update Ui.png
tyouwei Sep 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT

build.gradle
data/tasklist.txt
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
text-ui-test/runtest.bat

# Class files
src/main/java/*.class
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Duke project template
# chatbot.evan.Evan project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

Expand All @@ -13,7 +13,7 @@ Prerequisites: JDK 11, update Intellij to the most recent version.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
3. After that, locate the `src/main/java/chatbot.evan.Evan.java` file, right-click it, and choose `Run chatbot.evan.Evan.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
Expand Down
92 changes: 92 additions & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -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
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

72 changes: 72 additions & 0 deletions src/main/java/chatbot/evan/Evan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package chatbot.evan;

import java.util.Scanner;

import command.*;

import enums.Command;

import exception.InvalidInputException;
import exception.InvalidCommandException;
import exception.MissingArgumentException;

import parser.CommandParser;
import task.TaskList;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import statements neatly organized


import ui.Reply;

/**
* Main class for the chatbot
*/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good javadocs written throughout

public class Evan {

private static TaskList tasks = TaskList.init();
private static Reply reply = Reply.init();

/**
* main method of the Main class Evan chatbot
* Continuously takes in user input and gives an appropriate response until the user enters "bye
* @param args unused
*/
public static void main(String[] args) {
//Start user interaction
Scanner scanner = new Scanner(System.in);

while(true) {
try {
String input = scanner.nextLine().toLowerCase();

if (input.equals(Command.BYE.getCommand())) {
reply.printDialog("Bye. Hope to see you again soon!");
return;
} else if (input.equals(Command.LIST.getCommand())) {
tasks.printTasks();
} else if (input.equals(Command.TODO.getCommand())) {
ToDoCommand.start();
} else if (input.equals(Command.DEADLINE.getCommand())) {
DeadlineCommand.start();
} else if (input.equals(Command.EVENT.getCommand())) {
EventCommand.start();
} else if (input.startsWith(Command.DELETE.getCommand())) {
DeleteCommand.start(input);
} else if (input.startsWith(Command.MARK.getCommand())) {
MarkCommand.start(input);
} else if (input.startsWith(Command.UNMARK.getCommand())) {
UnmarkCommand.start(input);
} else if (input.startsWith(Command.FIND.getCommand())) {
FindCommand.start(input);
} else {
throw new InvalidCommandException();
}
} catch (InvalidInputException e) {
reply.printDialog(e.toString());
} catch (MissingArgumentException e) {
reply.printDialog(e.toString());
} catch (InvalidCommandException e) {
reply.printDialog(e.toString());
}
}
}


}
59 changes: 59 additions & 0 deletions src/main/java/command/DeadlineCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package command;

import exception.InvalidDateException;
import exception.InvalidTimeException;

import task.TaskList;
import task.Deadlines;

import ui.Reply;

import parser.Time;

import java.util.Scanner;

/**
* Class for Deadline command with its static implementation of its processes
*/
public class DeadlineCommand {
private static Reply reply = Reply.init();
private static TaskList tasks = TaskList.init();

/**
* Main process of Deadline Command.
* Prompts user to enter the task and deadline date and time before validating and adding it to the list.
* Returns to homepage otherwise.
*/
public static void start() {

Scanner scanner = new Scanner(System.in);

reply.printDialog("So you want to add a task with deadline. Tell me what's the task.");
String desc = scanner.nextLine();

reply.printDialog("Now indicate the deadline date.");
String date = scanner.nextLine();
try {
date = Time.formatDate(date);
} catch (InvalidDateException e) {
reply.printDialog(e.toString());
return;
}

reply.printDialog("Indicate a start time in ranging from 0000 - 2359. You may enter 'Skip' to not indicate a time");
String time = scanner.nextLine();
if (!time.toLowerCase().equals(enums.Command.SKIP.getCommand())) {
try {
date = Time.formatTime(date, time);
} catch (InvalidTimeException | InvalidDateException e) {
reply.printDialog(e.toString());
return;
} catch (NumberFormatException e) {
reply.printDialog("Non-numerical characters detected. Please enter numbers only. Returning to homepage...");
return;
}
}

tasks.addTask(new Deadlines(desc, date));
}
}
43 changes: 43 additions & 0 deletions src/main/java/command/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package command;

import exception.InvalidCommandException;
import exception.MissingArgumentException;
import exception.InvalidInputException;

import parser.CommandParser;

import task.TaskList;

import ui.Reply;

/**
* Class for Delete command with its static implementation of its processes
*/
public class DeleteCommand {
private static Reply reply = Reply.init();
private static TaskList tasks = TaskList.init();

/**
* Main process of Delete Command.
* Validates the input after the delete keyword in the string. Deletes the task if it's a vlid input.
* Returns to homepage otherwise.
* @param input String input containing the command and its arguments
* @throws InvalidInputException if the arguments after command is invalid
* @throws MissingArgumentException if the arguments after the command is missing
* @throws InvalidCommandException if the command in the string is invalid
*/
public static void start(String input) throws
InvalidInputException,
MissingArgumentException,
InvalidCommandException {

String number = CommandParser.getCommandArguments(input);
try {
tasks.deleteTask(Integer.parseInt(number));
} catch (NumberFormatException e ) {
reply.printDialog(" Strictly type 1 number only");
} catch (IndexOutOfBoundsException e) {
reply.printDialog(" Index number does not exist in our list");
}
}
}
84 changes: 84 additions & 0 deletions src/main/java/command/EventCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package command;

import exception.InvalidDateException;
import exception.InvalidTimeException;

import enums.Command;

import parser.Time;

import task.Events;
import task.TaskList;

import ui.Reply;

import java.util.Scanner;

/**
* Class for Event command with its static implementation of its processes
*/
public class EventCommand {
private static Reply reply = Reply.init();
private static TaskList tasks = TaskList.init();

/**
* Main process of Event Command.
* Prompts user to enter the task, start and end date/time before validating and adding it to the list.
* Returns to homepage otherwise.
*/
public static void start() {

Scanner scanner = new Scanner(System.in);

reply.printDialog("So you want to add a event task. Tell me what's the task.");
String desc = scanner.nextLine();

reply.printDialog("Now indicate the start date.");
String from = scanner.nextLine();
try {
from = Time.formatDate(from);
} catch (InvalidDateException e) {
reply.printDialog(e.toString());
return;
}

reply.printDialog("Indicate a start time in ranging from 0000 - 2359. You may enter 'Skip' to not indicate a time");
String fromTime = scanner.nextLine();
if (!fromTime.toLowerCase().equals(Command.SKIP.getCommand())) {
try {
from = Time.formatTime(from, fromTime);
} catch (InvalidTimeException | InvalidDateException e) {
reply.printDialog(e.toString());
return;
} catch (NumberFormatException e) {
reply.printDialog("Non-numerical characters detected. Please enter numbers only. Returning to homepage...");
return;
}
}

reply.printDialog("Now indicate the end date.");
String to = scanner.nextLine();
try {
to = Time.formatDate(to);
} catch (InvalidDateException e) {
reply.printDialog(e.toString());
return;
}

reply.printDialog("Indicate a start time in ranging from 0000 - 2359. You may enter 'Skip' to not indicate a time");
String toTime = scanner.nextLine();
if (!toTime.toLowerCase().equals(Command.SKIP.getCommand())) {
try {
to = Time.formatTime(to, toTime);
} catch (InvalidTimeException | InvalidDateException e) {
reply.printDialog(e.toString());
return;
} catch (NumberFormatException e) {
reply.printDialog("Non-numerical characters detected. Please enter numbers only. Returning to homepage...");
return;
}
}

tasks.addTask(new Events(desc, from, to));
}
}
Loading