-
Notifications
You must be signed in to change notification settings - Fork 197
[Himeth Thewmika] iP #193
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
Open
himethcodes
wants to merge
36
commits into
nus-cs2113-AY2425S2:master
Choose a base branch
from
himethcodes:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Himeth Thewmika] iP #193
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
ff10a43
Level-0: Rename, Greet, Exit
himethT 303dc88
Level-1: Echo feature added
himethT c346b3f
Level-2: Add and List feature implemented
himethT 3bf3953
Level-3: Mark as Done
himethT c7eed91
Completed Level-3: Mark as Done
himethT 939475c
Level-4: Added support for ToDos, Deadlines, and Events
himethT 58239b4
Add BuddyException class
himethT 64e7da9
Add BuddyException class
himethT ee484f5
implement error handling with BuddyException (Level-5)
himethT d724241
Implement Level-6: Task Deletion Feature
himethT db6f55b
Resolve merge conflicts
himethT 1dcf586
Implemented Level-6: Delete task feature
himethT 2efca9d
Resolved merge conflicts for Level-6
himethT a0701af
Refactored BuddyBot to A-MoreOOP structure
himethT 25b958f
Update README.md
himethcodes 54e1247
Update BuddyBot.java
himethcodes 515bb1e
Update BuddyException.java
himethcodes 6b72961
Update Command.java
himethcodes e583251
Update Deadline.java
himethcodes 88b9ad8
Update Event.java
himethcodes f5f9c94
Update Parser.java
himethcodes 2663883
Update Storage.java
himethcodes dc30117
Update Task.java
himethcodes eba159a
Update TaskList.java
himethcodes b9ae938
Update Todo.java
himethcodes 647ec96
Update Ui.java
himethcodes f8914fe
Update DeadlineCommand.java
himethcodes dfb635a
Update DeleteCommand.java
himethcodes 7931a0d
Update EventCommand.java
himethcodes 7726b63
Update ExitCommand.java
himethcodes bdccdac
Update FindCommand.java
himethcodes b348061
Update ListCommand.java
himethcodes 3d2d513
Update MarkCommand.java
himethcodes 72a3150
Update ToDoCommand.java
himethcodes 1a301d1
Update UnmarkCommand.java
himethcodes 8741aac
Update README.md
himethcodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # IDEA files | ||
| /.idea/ | ||
| /out/ | ||
| /*.iml | ||
|
|
||
| # Gradle build files | ||
| /.gradle/ | ||
| /build/ | ||
| src/main/resources/docs/ | ||
|
|
||
| # MacOS custom attributes files created by Finder | ||
| .DS_Store | ||
| *.iml | ||
| bin/ | ||
|
|
||
| /text-ui-test/ACTUAL.TXT | ||
| text-ui-test/EXPECTED-UNIX.TXT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Contributors | ||
|
|
||
| Display | Name | Github Profile | Homepage | ||
| ---|:---:|:---:|:---: | ||
|  | Jeffry Lum | [Github](https://github.com/j-lum/) | [Homepage](https://se.kasugano.moe) | ||
|  | Damith C. Rajapakse | [Github](https://github.com/damithc/) | [Homepage](https://www.comp.nus.edu.sg/~damithch/) | ||
| # I would like to join this list. How can I help the project | ||
|
|
||
| For more information, please refer to our [contributor's guide](https://oss-generic.github.io/process/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # BuddyBot project template | ||
|
|
||
| This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it. | ||
|
|
||
| ## Setting up in Intellij | ||
|
|
||
| Prerequisites: JDK 17, update Intellij to the most recent version. | ||
|
|
||
| 1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first) | ||
| 1. Open the project into Intellij as follows: | ||
| 1. Click `Open`. | ||
| 1. Select the project directory, and click `OK`. | ||
| 1. If there are any further prompts, accept the defaults. | ||
| 1. Configure the project to use **JDK 17** (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. | ||
| 1. After that, locate the `src/main/java/BuddyBot.java` file, right-click it, and choose `Run BuddyBot.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 | ||
| ____ _ | ||
| | _ \ _ _| | _____ | ||
| | | | | | | | |/ / _ \ | ||
| | |_| | |_| | < __/ | ||
| |____/ \__,_|_|\_\___| | ||
| ``` | ||
|
|
||
| **Warning:** Keep the `src\main\java` folder as the root folder for Java files (i.e., don't rename those folders or move Java files to another folder outside of this folder path), as this is the default location some tools (e.g., Gradle) expect to find Java files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # BuddyBot User Guide | ||
|
|
||
| // Update the title above to match the actual product name | ||
|
|
||
| // Product screenshot goes here | ||
|
|
||
| // Product intro goes here | ||
|
|
||
| ## Adding deadlines | ||
|
|
||
| // Describe the action and its outcome. | ||
|
|
||
| // Give examples of usage | ||
|
|
||
| Example: `keyword (optional arguments)` | ||
|
|
||
| // A description of the expected outcome goes here | ||
|
|
||
| ``` | ||
| expected output | ||
| ``` | ||
|
|
||
| ## Feature ABC | ||
|
|
||
| // Feature details | ||
|
|
||
|
|
||
| ## Feature XYZ | ||
|
|
||
| // Feature details |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class BuddyBot { | ||
| private static final int MAX_TASKS = 100; | ||
| private static Task[] tasks = new Task[MAX_TASKS]; | ||
| private static int taskCount = 0; | ||
|
|
||
| public static void main(String[] args) { | ||
| Scanner scanner = new Scanner(System.in); | ||
|
|
||
| printGreeting(); | ||
|
|
||
| while (true) { | ||
| String command = scanner.nextLine().trim(); | ||
|
|
||
| if (command.equals("bye")) { | ||
| printExitMessage(); | ||
| break; | ||
| } else if (command.equals("list")) { | ||
| printTaskList(); | ||
| } else if (command.startsWith("mark ")) { | ||
| markTaskAsDone(command); | ||
| } else if (command.startsWith("unmark ")) { | ||
| unmarkTask(command); | ||
| } else { | ||
| addTask(command); | ||
| } | ||
| } | ||
|
|
||
| scanner.close(); | ||
| } | ||
|
|
||
| private static void printGreeting() { | ||
| System.out.println("____________________________________________________________"); | ||
| System.out.println(" Hello! I'm BuddyBot"); | ||
| System.out.println(" What can I do for you?"); | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
|
|
||
| private static void printExitMessage() { | ||
| System.out.println("____________________________________________________________"); | ||
| System.out.println(" Bye. Hope to see you again soon!"); | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
|
|
||
| private static void addTask(String taskDescription) { | ||
| if (taskCount < MAX_TASKS) { | ||
| tasks[taskCount] = new Task(taskDescription); | ||
| taskCount++; | ||
| System.out.println("____________________________________________________________"); | ||
| System.out.println(" added: " + taskDescription); | ||
| System.out.println("____________________________________________________________"); | ||
| } else { | ||
| System.out.println("Task list is full!"); | ||
| } | ||
| } | ||
|
|
||
| private static void printTaskList() { | ||
| System.out.println("____________________________________________________________"); | ||
| if (taskCount == 0) { | ||
| System.out.println(" No tasks in the list!"); | ||
| } else { | ||
| System.out.println(" Here are the tasks in your list:"); | ||
| for (int i = 0; i < taskCount; i++) { | ||
| System.out.println(" " + (i + 1) + ". " + tasks[i]); | ||
| } | ||
| } | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
|
|
||
| private static void markTaskAsDone(String command) { | ||
|
||
| int taskIndex = getTaskIndex(command, "mark "); | ||
| if (taskIndex != -1) { | ||
| tasks[taskIndex].markAsDone(); | ||
| System.out.println("____________________________________________________________"); | ||
| System.out.println(" Nice! I've marked this task as done:"); | ||
| System.out.println(" " + tasks[taskIndex]); | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
| } | ||
|
|
||
| private static void unmarkTask(String command) { | ||
| int taskIndex = getTaskIndex(command, "unmark "); | ||
| if (taskIndex != -1) { | ||
| tasks[taskIndex].unmarkAsDone(); | ||
| System.out.println("____________________________________________________________"); | ||
| System.out.println(" OK, I've marked this task as not done yet:"); | ||
| System.out.println(" " + tasks[taskIndex]); | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
| } | ||
|
|
||
| private static int getTaskIndex(String command, String prefix) { | ||
| try { | ||
| int index = Integer.parseInt(command.substring(prefix.length())) - 1; | ||
| if (index >= 0 && index < taskCount) { | ||
| return index; | ||
| } else { | ||
| System.out.println("Invalid task number!"); | ||
| } | ||
| } catch (NumberFormatException e) { | ||
| System.out.println("Please enter a valid number."); | ||
| } | ||
| return -1; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| public class Task { | ||
| protected String description; | ||
| protected boolean isDone; | ||
|
|
||
| public Task(String description) { | ||
| this.description = description; | ||
| this.isDone = false; | ||
| } | ||
|
|
||
| public void markAsDone() { | ||
| isDone = true; | ||
| } | ||
|
|
||
| public void unmarkAsDone() { | ||
| isDone = false; | ||
| } | ||
|
|
||
| public String getStatusIcon() { | ||
| return (isDone ? "[X]" : "[ ]"); // X for done, space for not done | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return getStatusIcon() + " " + description; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Hello from | ||
| ____ _ | ||
| | _ \ _ _| | _____ | ||
| | | | | | | | |/ / _ \ | ||
| | |_| | |_| | < __/ | ||
| |____/ \__,_|_|\_\___| | ||
|
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| @ECHO OFF | ||
|
|
||
| REM create bin directory if it doesn't exist | ||
| if not exist ..\bin mkdir ..\bin | ||
|
|
||
| REM delete output from previous run | ||
| if exist ACTUAL.TXT del ACTUAL.TXT | ||
|
|
||
| REM compile the code into the bin folder | ||
| javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java | ||
| IF ERRORLEVEL 1 ( | ||
| echo ********** BUILD FAILURE ********** | ||
| exit /b 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 BuddyBot < input.txt > ACTUAL.TXT | ||
|
|
||
| REM compare the output to the expected output | ||
| FC ACTUAL.TXT EXPECTED.TXT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # create bin directory if it doesn't exist | ||
| if [ ! -d "../bin" ] | ||
| then | ||
| mkdir ../bin | ||
| fi | ||
|
|
||
| # delete output from previous run | ||
| if [ -e "./ACTUAL.TXT" ] | ||
| then | ||
| rm ACTUAL.TXT | ||
| fi | ||
|
|
||
| # compile the code into the bin folder, terminates if error occurred | ||
| if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/*.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 | ||
|
|
||
| # convert to UNIX format | ||
| cp EXPECTED.TXT EXPECTED-UNIX.TXT | ||
| dos2unix ACTUAL.TXT EXPECTED-UNIX.TXT | ||
|
|
||
| # compare the output to the expected output | ||
| diff ACTUAL.TXT EXPECTED-UNIX.TXT | ||
| if [ $? -eq 0 ] | ||
| then | ||
| echo "Test result: PASSED" | ||
| exit 0 | ||
| else | ||
| echo "Test result: FAILED" | ||
| exit 1 | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments are missing for most methods and classes. Please add them as they increase the readability of the code.