Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0897fa1
Level 0. Rename, Greet, Exit
EdwinTun98 Feb 9, 2025
0773441
Level 1. Echo
EdwinTun98 Feb 10, 2025
479267b
no message
EdwinTun98 Feb 10, 2025
bd94a75
Revert "no message"
EdwinTun98 Feb 10, 2025
955c3e1
Reapply "no message"
EdwinTun98 Feb 10, 2025
ae75c2a
Level 2. Add, List
EdwinTun98 Feb 10, 2025
285ef87
Merge branch 'master' of https://github.com/EdwinTun98/ip
EdwinTun98 Feb 10, 2025
bd6973c
Level 3. Mark as Done
EdwinTun98 Feb 10, 2025
5950407
A-CodingStandard
EdwinTun98 Feb 10, 2025
1127f7c
Level 4. ToDos, Events, Deadlines
EdwinTun98 Feb 11, 2025
c907615
A-CodeQuality
EdwinTun98 Feb 12, 2025
4165887
Level 5. Handle Errors
EdwinTun98 Feb 12, 2025
f8fa3b7
Level 5. Handle Errors
EdwinTun98 Feb 13, 2025
0053c3f
Refactored Add task to processUserInput switch block. created helper …
EdwinTun98 Feb 13, 2025
76e13a6
Level 5. Handle Errors
EdwinTun98 Feb 14, 2025
372b6cb
Merge branch branch-Level-5
EdwinTun98 Feb 14, 2025
a1fcc37
Level 6. Delete
EdwinTun98 Feb 23, 2025
fbea3ba
Level 7. Save
EdwinTun98 Feb 25, 2025
b98d8fb
Merge branch 'branch-Level-6'
EdwinTun98 Feb 25, 2025
2b74ebe
Merge branch 'branch-Level-7'
EdwinTun98 Feb 25, 2025
2d8efdc
A-MoreOOP
EdwinTun98 Mar 29, 2025
9d97e23
Level 8. Dates and Times
EdwinTun98 Mar 30, 2025
28d5f33
Merge branch 'branch-Level-8'
EdwinTun98 Mar 30, 2025
a7cd70a
Level 9. Find
EdwinTun98 Mar 30, 2025
08c89bf
Level 9. Find
EdwinTun98 Mar 30, 2025
205be7f
A-JavaDoc: JavaDoc
EdwinTun98 Mar 30, 2025
0929cc2
A-UserGuide
EdwinTun98 Mar 31, 2025
db618cb
A-UserGuide updated
EdwinTun98 Mar 31, 2025
26414e0
Create _config.yml
EdwinTun98 Mar 31, 2025
efd9e14
A-UserGuide updated 2
EdwinTun98 Mar 31, 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
7 changes: 7 additions & 0 deletions data/tasks.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
T | 0 | read
D | 0 | submit assignment | 2025-04-01 1800
E | 0 | group meeting | 2025-04-02 1000 | 2025-04-02 1200
T | 0 | read book
T | 0 | read book
D | 0 | return book | 2025-04-01 1800
E | 0 | group project meeting | 2025-04-02 1400 | 2025-04-02 1600
157 changes: 143 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,159 @@
# Duke User Guide
# Eddie Task Manager!
```
_____ ____ ____ ___ _____
| ____|| _ \ | _ \ |_ _|| ____|
| |_ | | | || | | | | | | |_
| _| | | | || | | | | | | |_|
| |___ | |_| || |_| | | | | |___
|_____||____/ |____/ |___||_____|

// Update the title above to match the actual product name
Eddie: Welcome to your personal task manager!
I can help you manage different types of tasks.
```

// Product screenshot goes here
# Eddie User Guide

// Product intro goes here
## Introduction

## Adding deadlines
**Eddie** is a command-line based chatbot designed to help you organize your tasks. Whether it’s a **Todo**, a **Deadline**, or an **Event** Eddie has you covered! Eddie understands natural-like commands and can **add, list, delete, mark, unmark, find** and even **remember your tasks between sessions** with **date parsing** and **search** features!

// Describe the action and its outcome.
---
# Features
## Adding Tasks

// Give examples of usage
### Add ToDo, Deadline, or Event Tasks

Example: `keyword (optional arguments)`
- `todo {description}` – Adds a ToDo task
- `deadline {description} /by {yyyy-MM-dd HHmm}` – Adds a Deadline
- `event {description} /from {yyyy-MM-dd HHmm} /to {yyyy-MM-dd HHmm}` – Adds an Event

// A description of the expected outcome goes here

Example: adding tasks
```
____________________________________________________________
You: todo read book
____________________________________________________________
Eddie:
Got it. I've added this task:
[T][ ] read book
Now you have 1 task in the list.
____________________________________________________________
```
```
____________________________________________________________
You: deadline return book /by 2025-04-01 1800
____________________________________________________________
Eddie:
Got it. I've added this task:
[D][ ] return book (by: Apr 1 2025, 6:00pm)
Now you have 2 tasks in the list.
____________________________________________________________
```
expected output
```
__________________________________________________________________________________
You: event group project meeting /from 2025-04-02 1400 /to 2025-04-02 1600
__________________________________________________________________________________
Eddie:
Got it. I've added this task:
[E][ ] group project meeting (from: Apr 2 2025, 2:00pm to: Apr 2 2025, 4:00pm)
Now you have 3 tasks in the list.
__________________________________________________________________________________
```

---

### List All Tasks

- `list` – Shows all tasks currently tracked.

#### Example:
```
__________________________________________________________________________________
You: list
__________________________________________________________________________________
Eddie:
Here are the tasks in your list:
1. [T][ ] read book
2. [D][ ] return book (by: Apr 1 2025, 6:00pm)
3. [E][ ] group project meeting (from: Apr 2 2025, 2:00pm to: Apr 2 2025, 4:00pm)
__________________________________________________________________________________
```

---

### Mark/Unmark Tasks

- `mark {task number}` – Mark a task as done
- `unmark {task number}` – Mark a task as not done

#### Example:
```
____________________________________________________________
You: mark 1
____________________________________________________________
Eddie:
Yay! Marked as done:
[T][X] read book
Have a Beer!!
____________________________________________________________
You: unmark 1
____________________________________________________________
Eddie:
Oh no! Marked as not done:
[T][ ] read book
____________________________________________________________
```

---

### Delete a Task

- `delete {task number}` – Deletes the selected task from the list.

#### Example:
```
____________________________________________________________
You: delete 2
____________________________________________________________
Eddie:
Noted. I've removed this task:
[D][ ] return book (by: Apr 1 2025, 6:00pm)
Now you have 2 tasks in the list.
____________________________________________________________
```

---

### Find Tasks

- `find {keyword}` – Search and display tasks that match the keyword.

#### Example:
```
____________________________________________________________
You: find book
____________________________________________________________
Eddie:
Here are the tasks matching your list:
1. [T][ ] read book
2. [D][ ] return book (by: Apr 1 2025, 6:00pm)
____________________________________________________________
```

---

### Storage

Eddie saves your task list in a text file at `data/tasks.txt`, and loads it every time you start the app.

## Feature ABC
---

// Feature details
## How to Use

1. Clone this repo and build the project in your IDE
2. Run `Eddie.java`.
3. Interact with Eddie through the terminal using the supported commands above.
4. Exit using the command `bye`.

## Feature XYZ
---

// Feature details
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-midnight
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

60 changes: 60 additions & 0 deletions src/main/java/Eddie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import command.Command;
import command.EddieException;
import parser.Parser;
import storage.Storage;
import tasklist.TaskList;
import ui.Ui;

/**
* The main class for the Eddie chatbot task manager.
*/
public class Eddie {
private Ui ui;
private Storage storage;
private TaskList tasks;

/**
* Initializes Eddie with the default storage file path.
*/
public Eddie(String filePath) {
ui = new Ui();
storage = new Storage(filePath);

try {
tasks = new TaskList(storage.loadTask());
} catch (EddieException e) {
ui.showLoadingError();
tasks = new TaskList();
}
}

/**
* Starts the Eddie chatbot.
*/
public void run() {
ui.showStartPage();
boolean isRunning = true;

while (isRunning) {
String userInput = ui.readCommand();
ui.printLine();
try {
Command command = Parser.parse(userInput);
command.execute(tasks, ui, storage);
if (command.isExit()) {
isRunning = false;
}
} catch (EddieException e) {
ui.showError(e.getMessage());
}
ui.printLine();
}
}

/**
* Entry point for the program.
*/
public static void main(String[] args) {
new Eddie("data/tasks.txt").run();
}
}
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: Eddie

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

import storage.Storage;
import tasklist.TaskList;
import ui.ErrorMessages;
import ui.Ui;
import task.Todo;
import task.Deadline;
import task.Event;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/**
* Represents a command to add a new task todo, deadline and event.
*/
public class AddCommand extends Command {
private final String taskDetails;
private final String taskType;

public AddCommand(String taskDetails, String taskType) {
this.taskDetails = taskDetails;
this.taskType = taskType;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) throws EddieException {
switch (taskType) {
case "todo":
if (taskDetails.isEmpty()) {
throw new EddieException(ErrorMessages.INVALID_TODO);
}
tasks.addTask(new Todo(taskDetails));
break;
case "deadline":
String[] deadlineParts = taskDetails.split(" /by ", 2);
if (deadlineParts.length < 2 || deadlineParts[0].trim().isEmpty()) {
throw new EddieException(ErrorMessages.INVALID_DEADLINE);
}
try {
DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm");
LocalDateTime by = LocalDateTime.parse(deadlineParts[1].trim(), inputFormat);
tasks.addTask(new Deadline(deadlineParts[0].trim(), by));
} catch (DateTimeParseException e) {
throw new EddieException(ErrorMessages.INVALID_DEADLINE);
}
break;
case "event":
String[] eventParts = taskDetails.split(" /from ", 2);
if (eventParts.length < 2 || !eventParts[1].contains(" /to ") || eventParts[0].trim().isEmpty()) {
throw new EddieException(ErrorMessages.INVALID_EVENT);
}
String[] timeParts = eventParts[1].split(" /to ", 2);
try {
DateTimeFormatter inputFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm");
LocalDateTime from = LocalDateTime.parse(timeParts[0].trim(), inputFormat);
LocalDateTime to = LocalDateTime.parse(timeParts[1].trim(), inputFormat);
tasks.addTask(new Event(eventParts[0].trim(), from, to));
} catch (DateTimeParseException e) {
throw new EddieException(ErrorMessages.INVALID_EVENT);
}
break;
default:
throw new EddieException(ErrorMessages.INVALID_COMMAND);
}

// Show confirm task to user and save tasks
ui.showTaskAdded(tasks.getLastTask(), tasks.size());
storage.saveTasks(tasks.getAllTasks());
}
}
26 changes: 26 additions & 0 deletions src/main/java/command/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package command;

import storage.Storage;
import tasklist.TaskList;
import ui.Ui;

/**
* Abstract base class for all user commands.
*/
public abstract class Command {
/**
* Executes the command with the provided task list, UI, and storage.
*
* @param tasks The task list to operate on.
* @param ui The UI to interact with the user.
* @param storage The storage to save and load data.
* @throws EddieException for error occurs during command execution.
*/
public abstract void execute(TaskList tasks, Ui ui, Storage storage) throws EddieException;

public boolean isExit() {
return false;
}
}


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

import storage.Storage;
import tasklist.TaskList;
import ui.Ui;
import task.Task;

public class DeleteCommand extends Command {
private String taskIndex;

public DeleteCommand(String taskIndex) {
this.taskIndex = taskIndex;
}

@Override
public void execute(TaskList tasks, Ui ui, Storage storage) {
try {
int index = Integer.parseInt(taskIndex) - 1;
Task removedTask = tasks.removeTask(index);
ui.showTaskDeleted(removedTask, tasks.size());
storage.saveTasks(tasks.getAllTasks());

} catch (NumberFormatException | EddieException e) {
ui.showError("Invalid task number!");
}
}
}
8 changes: 8 additions & 0 deletions src/main/java/command/EddieException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package command;

public class EddieException extends Exception {
public EddieException(String message) {
super(message);
}
}

Loading