Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
817846f
level 0
lhlim88 Feb 8, 2025
c5fd455
level 1
lhlim88 Feb 8, 2025
50c81a9
level 2
lhlim88 Feb 15, 2025
4e9d824
level 3
lhlim88 Feb 27, 2025
340187b
level 4
lhlim88 Mar 1, 2025
b56022f
removing spaces in input
lhlim88 Mar 3, 2025
487f813
added exception for todo, deadline and event
lhlim88 Mar 3, 2025
ea54e99
added exception for mark, unmark & invalid input
lhlim88 Mar 3, 2025
278b61f
all exceptions added, level 5 complete
lhlim88 Mar 3, 2025
e440954
Merged Level-5 into master
lhlim88 Mar 3, 2025
073a202
added delete command
lhlim88 Mar 4, 2025
6da1f44
Merge branch-Level-6 into master
lhlim88 Mar 8, 2025
6973f03
Level 7
lhlim88 Mar 8, 2025
c1c2e94
Merge branch-Level-7 into master
lhlim88 Mar 8, 2025
59e4fd5
A-MoreOOP
lhlim88 Mar 9, 2025
e87ecaa
Level-9
lhlim88 Mar 9, 2025
d1b0245
solved error
lhlim88 Mar 9, 2025
17cf10a
resolve exception error
lhlim88 Mar 11, 2025
6eec05d
checked for code quality
lhlim88 Mar 12, 2025
65581d7
added javadoc comments
lhlim88 Mar 12, 2025
5151f5f
Update README.md
lhlim88 Mar 14, 2025
48fc7c4
Update README.md 2nd time
lhlim88 Mar 14, 2025
18c5c52
Update README.md 3rd time
lhlim88 Mar 14, 2025
169974a
Update README.md
lhlim88 Mar 14, 2025
ef36226
Update UG
lhlim88 Mar 14, 2025
19ff875
Update UG 2nd time
lhlim88 Mar 14, 2025
2d33c75
testing format for UG
lhlim88 Mar 14, 2025
db1c9b3
ensure correct format for UG
lhlim88 Mar 14, 2025
6651a07
UG formatting
lhlim88 Mar 14, 2025
1579be4
adjustments
lhlim88 Mar 14, 2025
ef38112
erge branch 'master' of https://github.com/limleyhooi/ip
lhlim88 Mar 14, 2025
16a4000
more edits
lhlim88 Mar 14, 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
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Duke project template
# Rick 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.
This is a project template for a greenfield Java project. Given below are instructions on how to use it.

## Setting up in Intellij

Expand All @@ -13,14 +13,16 @@ Prerequisites: JDK 17, update Intellij to the most recent version.
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/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:
1. After that, locate the `src/main/java/Rick.java` file, right-click it, and choose `Run Rick.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
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
____ _ _
| _ \(_) ___| | __
| |_) | |/ __| |/ /
| _ <| | (__| <
|_| \_\_|\___|_|\_\
Hello, I'm Rick (´。• ᵕ •。`)
What can I do for you?
```

**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.
7 changes: 7 additions & 0 deletions data/Rick.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
T | 0 | math
T | 0 | science hw
D | 0 | null | friday
E | 0 | null | 10:00 | 11:00
D | 0 | null | today
D | 0 | apple | today
E | 0 | hw | today | tmr
100 changes: 84 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,98 @@
# Duke User Guide
# Rick User Guide

// Update the title above to match the actual product name
<img width="581" alt="image" src="https://github.com/user-attachments/assets/5c34e679-4696-4c55-a0b9-721ef92b6210" />

// Product screenshot goes here
Rick is an expressive and friendly chatbot that helps you manage your tasks. With Rick, you can add tasks, set deadlines, schedule events, and more. This guide explains how to use all of Rick’s features.

## How to run Rick:
1. Copy the jar file into an empty folder (you can find Rick.jar in the github release mechanism)
2. Open a command window in that folder.
3. Run the command java -jar Rick.jar (i.e., run the command in the same folder as the jar file).

After starting, Rick will display a welcome message. Yay! you can start interacting with Rick by typing in your command and press enter.

# Available Commands

## 1. Existing Rick

command: bye

what it does: closes Rick.

<img width="558" alt="image" src="https://github.com/user-attachments/assets/13dc2369-d537-4abc-a424-326a7bf084ff" />

## 2. Listing All Tasks

command: list

what it does: Shows all the tasks you have added.

<img width="518" alt="image" src="https://github.com/user-attachments/assets/7346789e-9cbb-4d8e-8337-ee041441eb7a" />

## 3. Finding Task

command: find <keyword>

what it does: search for task that contains a specific word.

<img width="525" alt="image" src="https://github.com/user-attachments/assets/d26a3e30-d0f9-4dd3-ae56-1bd0c9e1fea0" />

## 4. Marking Task as Done

command: mark <task number>

what it does: mark the task with "X"

<img width="513" alt="image" src="https://github.com/user-attachments/assets/01c88efd-b7cd-4784-ba2e-d330fd4b1001" />

## 5. Marking Task as Undone

command: unmark <task number>

what it does: remove the "X" mark on task

<img width="531" alt="image" src="https://github.com/user-attachments/assets/40cbee9a-e135-4ab2-b38c-65f070e7c4f1" />

## 6. Deleting a Task

command: delete <task number>

what it does: remove a task from your list

<img width="519" alt="image" src="https://github.com/user-attachments/assets/af1c5397-9a02-44f0-a0ac-8030b7b7801b" />

## 7. Adding a Todo Task

command: todo <description>

what it does: Adds a task

<img width="515" alt="image" src="https://github.com/user-attachments/assets/d7d74eb8-d38b-4d65-a6d9-a5ffa11a1509" />

## 8. Adding a Deadline Task

command: deadline <description> /by <date>

what it does: Adds a task with deadline

<img width="526" alt="image" src="https://github.com/user-attachments/assets/920d226e-634f-4b9e-a9d7-fdef79f9f840" />

## 9. Adding an Event task

command: event <description> /from <start time> /to <end time>

what it does: Adds a task with start time and end time

<img width="521" alt="image" src="https://github.com/user-attachments/assets/a6fa41c0-3814-4c68-9e8b-f6bdd56c7103" />

// 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
17 changes: 17 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
public class Deadline extends Task{

protected String date;
public Deadline(String description, String date){
super(description);
this.date = date;
}
@Override
public String toString(){
return "[D]" + super.toString() + " (by: " + date + ")";
}
@Override
public String toDataString() {
// Format: D | 1/0 | description | date
return "D | " + (isDone ? "1" : "0") + " | " + this.description + " | " + this.date;
}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class Event extends Task{

protected String startTime;
protected String endTime;
public Event(String description, String startTime, String endTime){
super(description);
this.startTime = startTime;
this.endTime = endTime;
}
@Override
public String toString(){
return "[E]" + super.toString() + " (from: " + startTime + " to: " + endTime + ")";
}
@Override
public String toDataString() {
// Format: E | 1/0 | description | startTime| endTime
return "E | " + (isDone ? "1" : "0") + " | " + this.description + " | " + this.startTime + " | " + this.endTime;
}
}
3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: Rick

112 changes: 112 additions & 0 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import java.util.ArrayList;

/**
*Identify key command words such as "bye", "list", "find", "mark", "unmark", "delete", "todo", "deadline" and "event".
*/
public class Parser {

/**
*
* @param input
* @param taskList
* @param storage
* @param ui
* @return true to exit program. If return false, while loop in Rick class will keep running parse method.
*/
public static boolean parse(String input, TaskList taskList, Storage storage, Ui ui) {
String trimmedInput = input.trim();

if (trimmedInput.equals("bye")) {
ui.showGoodbye();
return true; // signal to exit the program
} else if (trimmedInput.equals("list")) {
ui.showTaskList(taskList.getTasks());
}
else if (trimmedInput.startsWith("find")) { // NEW: find command
String keyword = trimmedInput.substring(4).trim();
if (keyword.isEmpty()) {
ui.showError("The search keyword cannot be empty. (✖╭╮✖)\n");
} else {
// Use TaskList's findTasks method to search for tasks containing the keyword
ArrayList<Task> foundTasks = taskList.findTasks(keyword);
ui.showFoundTasks(foundTasks);
}
}
else if (trimmedInput.startsWith("mark")) {
try {
String noSpace = trimmedInput.replaceAll("\\s","");
int index = Integer.parseInt(noSpace.substring(4)) - 1;
Task task = taskList.getTask(index);
task.markAsDone();
ui.showTaskDone(task);
storage.saveTasks(taskList.getTasks());
} catch (NumberFormatException | IndexOutOfBoundsException e) {
ui.showError("Invalid task number for marking! (✖ _ ✖)\n");
}
} else if (trimmedInput.startsWith("unmark")) {
try {
String noSpace = trimmedInput.replaceAll("\\s","");
int index = Integer.parseInt(noSpace.substring(6)) - 1;
Task task = taskList.getTask(index);
task.markAsUndone();
ui.showTaskUndone(task);
storage.saveTasks(taskList.getTasks());
} catch (NumberFormatException | IndexOutOfBoundsException e) {
ui.showError("Invalid task number for unmarking! (´・_・`)");
}
} else if (trimmedInput.startsWith("delete")) {
try {
String noSpace = trimmedInput.replaceAll("\\s","");
int index = Integer.parseInt(noSpace.substring(6)) - 1;
taskList.deleteTask(index);
ui.showTaskDeleted();
storage.saveTasks(taskList.getTasks());
} catch (NumberFormatException | IndexOutOfBoundsException e) {
ui.showError("Invalid task number for deletion! (´;︵;`)");
}
} else if (trimmedInput.startsWith("todo")) {
String description = trimmedInput.substring(4).trim();
if (description.isEmpty()) {
ui.showError("The description of a todo cannot be empty. (。•́︿•̀。)");
} else {
Task task = new Todo(description);
taskList.addTask(task);
ui.showTaskAdded(task, taskList.size());
storage.saveTasks(taskList.getTasks());
}
} else if (trimmedInput.startsWith("deadline")) {
String[] parts = trimmedInput.substring(8).split("/by", 2);
if (parts.length < 2 || parts[0].trim().isEmpty() || parts[1].trim().isEmpty()) {
ui.showError("Your deadline task needs a description and a due date.\nFormat: deadline <description> /by <date>");
} else {
String description = parts[0].trim();
String by = parts[1].trim();
Task task = new Deadline(description, by);
taskList.addTask(task);
ui.showTaskAdded(task, taskList.size());
storage.saveTasks(taskList.getTasks());
}
} else if (trimmedInput.startsWith("event")) {
// Expecting format: event <description> /from <start> /to <end>
String[] parts = trimmedInput.substring(5).split("/from|/to");
if (parts.length < 3 ||
parts[0].trim().isEmpty() ||
parts[1].trim().isEmpty() ||
parts[2].trim().isEmpty()) {
ui.showError("Your event task needs a description and times.\nFormat: event <description> /from <start time> /to <end time>");
} else {
String description = parts[0].trim();
String from = parts[1].trim();
String to = parts[2].trim();
Task task = new Event(description, from, to);
taskList.addTask(task);
ui.showTaskAdded(task, taskList.size());
storage.saveTasks(taskList.getTasks());
}
} else {
ui.showError("I'm sorry, but I don't know what that means. (・・)?");
}
return false;
}
}

21 changes: 21 additions & 0 deletions src/main/java/Rick.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* The main entry point of the application.
*/



public class Rick {
public static void main(String[] args) {
Ui ui = new Ui();
Storage storage = new Storage();
TaskList taskList = new TaskList(storage.loadTasks());

ui.showWelcome();

boolean exit = false;
while (!exit) {
String input = ui.readCommand();
exit = Parser.parse(input, taskList, storage, ui);
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/RickException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public class RickException extends Exception{
//empty;
}
Loading