Skip to content
Open
Show file tree
Hide file tree
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 Feb 7, 2025
303dc88
Level-1: Echo feature added
himethT Feb 7, 2025
c346b3f
Level-2: Add and List feature implemented
himethT Feb 7, 2025
3bf3953
Level-3: Mark as Done
himethT Feb 7, 2025
c7eed91
Completed Level-3: Mark as Done
himethT Feb 7, 2025
939475c
Level-4: Added support for ToDos, Deadlines, and Events
himethT Feb 8, 2025
58239b4
Add BuddyException class
himethT Feb 14, 2025
64e7da9
Add BuddyException class
himethT Feb 14, 2025
ee484f5
implement error handling with BuddyException (Level-5)
himethT Feb 24, 2025
d724241
Implement Level-6: Task Deletion Feature
himethT Feb 24, 2025
db6f55b
Resolve merge conflicts
himethT Mar 1, 2025
1dcf586
Implemented Level-6: Delete task feature
himethT Mar 1, 2025
2efca9d
Resolved merge conflicts for Level-6
himethT Mar 1, 2025
a0701af
Refactored BuddyBot to A-MoreOOP structure
himethT Mar 13, 2025
25b958f
Update README.md
himethcodes Mar 13, 2025
54e1247
Update BuddyBot.java
himethcodes Apr 1, 2025
515bb1e
Update BuddyException.java
himethcodes Apr 1, 2025
6b72961
Update Command.java
himethcodes Apr 1, 2025
e583251
Update Deadline.java
himethcodes Apr 1, 2025
88b9ad8
Update Event.java
himethcodes Apr 1, 2025
f5f9c94
Update Parser.java
himethcodes Apr 1, 2025
2663883
Update Storage.java
himethcodes Apr 1, 2025
dc30117
Update Task.java
himethcodes Apr 1, 2025
eba159a
Update TaskList.java
himethcodes Apr 1, 2025
b9ae938
Update Todo.java
himethcodes Apr 1, 2025
647ec96
Update Ui.java
himethcodes Apr 1, 2025
f8914fe
Update DeadlineCommand.java
himethcodes Apr 1, 2025
dfb635a
Update DeleteCommand.java
himethcodes Apr 1, 2025
7931a0d
Update EventCommand.java
himethcodes Apr 1, 2025
7726b63
Update ExitCommand.java
himethcodes Apr 1, 2025
bdccdac
Update FindCommand.java
himethcodes Apr 1, 2025
b348061
Update ListCommand.java
himethcodes Apr 1, 2025
3d2d513
Update MarkCommand.java
himethcodes Apr 1, 2025
72a3150
Update ToDoCommand.java
himethcodes Apr 1, 2025
1a301d1
Update UnmarkCommand.java
himethcodes Apr 1, 2025
8741aac
Update README.md
himethcodes Apr 1, 2025
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
17 changes: 17 additions & 0 deletions ip/.gitignore
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
9 changes: 9 additions & 0 deletions ip/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributors

Display | Name | Github Profile | Homepage
---|:---:|:---:|:---:
![](https://avatars0.githubusercontent.com/u/22460123?s=100) | Jeffry Lum | [Github](https://github.com/j-lum/) | [Homepage](https://se.kasugano.moe)
![](https://avatars0.githubusercontent.com/u/1673303?s=100) | 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/).
26 changes: 26 additions & 0 deletions ip/README.md
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.
30 changes: 30 additions & 0 deletions ip/docs/README.md
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
106 changes: 106 additions & 0 deletions ip/src/main/java/BuddyBot.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import java.util.Scanner;

public class BuddyBot {
Copy link
Copy Markdown

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.

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) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

small methods make the code modular and easy to read

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;
}
}
26 changes: 26 additions & 0 deletions ip/src/main/java/Task.java
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;
}
}
7 changes: 7 additions & 0 deletions ip/text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

Empty file added ip/text-ui-test/input.txt
Empty file.
21 changes: 21 additions & 0 deletions ip/text-ui-test/runtest.bat
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
38 changes: 38 additions & 0 deletions ip/text-ui-test/runtest.sh
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