Duke is a command-line interface (CLI) chatbot that helps users manage their tasks, events, and deadlines through natural language interaction. Built in Java, it demonstrates object-oriented programming principles and clean architecture design.
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
Hello! I'm Duke 🤖
What can I do for you today?
-
Add Tasks: Create different types of tasks
todo read book deadline return book /by Sunday event team meeting /at Mon 2-4pm
-
List Tasks: View all tasks
list 1.[✓] read book 2.[✗] return book (by: Sunday) 3.[✗] team meeting (at: Mon 2-4pm)
-
Mark Tasks: Mark tasks as done
done 1 Marked this task as done: [✓] read book
-
Delete Tasks: Remove tasks
delete 2 Removed this task: [✗] return book (by: Sunday)
- Automatically saves tasks to local storage
- Loads previous tasks on startup
- Maintains task state between sessions
src/
├── main/
│ ├── java/
│ │ ├── duke/
│ │ │ ├── Duke.java # Main application class
│ │ │ ├── command/ # Command pattern implementation
│ │ │ ├── parser/ # Input parsing logic
│ │ │ ├── storage/ # Data persistence
│ │ │ ├── task/ # Task-related classes
│ │ │ └── ui/ # User interface
│ └── resources/
└── test/
└── java/
└── duke/ # Test classes
- Command Pattern: For executing different user commands
- Singleton Pattern: For storage management
- Factory Pattern: For creating different task types
- JDK 11 or higher
- IntelliJ IDEA (recommended)
- Clone the repository
git clone https://github.com/yourusername/duke.git
- Open in IntelliJ IDEA
- Click
Open
- Select the project directory
- Wait for project indexing to complete
- Configure JDK
- Set Project SDK to JDK 11
- Set Project language level to SDK default
- Run the application
./gradlew run
./gradlew test
> todo read book
Got it. I've added this task:
[✗] read book
Now you have 1 tasks in the list.
> deadline return book /by Sunday
Got it. I've added this task:
[✗] return book (by: Sunday)
Now you have 2 tasks in the list.
> done 1
Nice! I've marked this task as done:
[✓] read book
> find book
Here are the matching tasks in your list:
1.[✓] read book
2.[✗] return book (by: Sunday)
> done 999
☹ OOPS!!! The task number is invalid.
> todo
☹ OOPS!!! The description of a todo cannot be empty.
- Task creation and manipulation
- Command parsing
- Storage operations
- End-to-end command execution
- Data persistence
- Error handling
Main class that orchestrates the chatbot's operations
public class Duke {
private Storage storage;
private TaskList tasks;
private Ui ui;
public Duke(String filePath) {
// Initialize components
}
public void run() {
// Main operation loop
}
}
Base class for all task types
public abstract class Task {
protected String description;
protected boolean isDone;
public Task(String description) {
this.description = description;
this.isDone = false;
}
// Common task methods
}
- Uses text file for persistence
- Custom serialization format
- Atomic write operations
- Custom exceptions for different scenarios
- Graceful error recovery
- User-friendly error messages
- Command parsing using regex
- Flexible date/time format parsing