Skip to content
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

[Xu JiaChen]iP #60

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ed3efe1
Add Dude Level 0
aaronxujiachen Aug 22, 2023
c6302e9
Add Dude Level 1
aaronxujiachen Sep 2, 2023
8d766a7
Add Dude Level 2
aaronxujiachen Sep 2, 2023
6eb2ef3
Add Dude Level 3
aaronxujiachen Sep 2, 2023
2cf44fb
Tweak the code to comply with coding standard
aaronxujiachen Sep 2, 2023
79f86ed
Add Dude Level 4
aaronxujiachen Sep 9, 2023
c310414
Improve Code Quality
aaronxujiachen Sep 9, 2023
dae8f4d
Rename Main Class
aaronxujiachen Sep 14, 2023
507e70b
Add Dude Level 5
aaronxujiachen Sep 16, 2023
47c336c
Merge branch 'branch-Level-5'
aaronxujiachen Sep 16, 2023
08a8f29
Organize All Classes Into A Package
aaronxujiachen Sep 16, 2023
4c76995
Merge branch 'branch-A-Packages'
aaronxujiachen Sep 16, 2023
317108a
Add Dude Level 6
aaronxujiachen Sep 20, 2023
898968d
Add Dude Level 7
aaronxujiachen Sep 21, 2023
564c8ee
Revert "Add Dude Level 7"
aaronxujiachen Sep 21, 2023
6a62116
Add Dude Level 7
aaronxujiachen Sep 21, 2023
45ac2de
Merge branch 'branch-Level-7'
aaronxujiachen Sep 21, 2023
12bfeb7
Refactor the code to make it more OOP
aaronxujiachen Sep 28, 2023
c2b4e7c
Add Dude Level 9
aaronxujiachen Sep 29, 2023
63adef5
Add Comments For Dude
aaronxujiachen Oct 2, 2023
c9d74d9
Merge pull request #2 from aaronxujiachen/branch-Level-9
aaronxujiachen Oct 3, 2023
7b95f42
Merge branch 'master' into branch-A-JavaDoc
aaronxujiachen Oct 3, 2023
3547e34
Merge pull request #3 from aaronxujiachen/branch-A-JavaDoc
aaronxujiachen Oct 3, 2023
64b0893
Resolve Merge Conflict
aaronxujiachen Oct 3, 2023
85bb25c
Update README.md
aaronxujiachen Oct 3, 2023
0d42444
Update README.md
aaronxujiachen Oct 3, 2023
76e80b4
Update README.md
aaronxujiachen Oct 3, 2023
a1189ae
Update UserGuide Website
aaronxujiachen Oct 5, 2023
c7dbfd9
Change the Path of dude.txt
aaronxujiachen Oct 5, 2023
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
83 changes: 59 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,59 @@
# Duke 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 11, 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 11** (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.
3. 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:
```
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
# Dude Chatbot User Guide

Welcome to Dude, your trusty task management chatbot. Dude helps you stay organized by keeping track of your tasks, whether they're to-dos, deadlines, or events. This user guide will provide you with the essential information to make the most of Dude's features.


## Getting Started

To get started with Dude, follow these steps:

1. Ensure you have Java Development Kit (JDK) 11 installed on your computer.
2. Make sure you have the latest version of IntelliJ IDEA installed.
3. Clone or download the Dude project repository.

## Setting Up Dude in IntelliJ IDEA

1. Open IntelliJ IDEA.
2. If you have an existing project open, close it.
3. Click on "File" > "Open" and select the Dude project directory.
4. Configure the project to use JDK 11:
- Click on "File" > "Project Structure."
- Under "Project," set the "Project SDK" to JDK 11.
- Set the "Project language level" to "SDK default."

## Running Dude

1. Locate the `Dude.java` file in the `src/main/java` directory of the Dude project.
2. Right-click on `Dude.java` and select "Run Dude.main()".
3. If everything is set up correctly, Dude will start, and you'll see a greeting message.

## Using Dude

Dude understands various commands to manage your tasks. Here are some essential commands:

- `list`: List all tasks in your task list.
- `todo <description>`: Add a to-do task.
- `deadline <description> /by <due_date>`: Add a deadline task.
- `event <description> /from <start_date> /to <end_date>`: Add an event task.
- `mark <task_index>`: Mark a task as done.
- `unmark <task_index>`: Mark a task as not done.
- `delete <task_index>`: Delete a task from the list.
- `find <keyword>`: Find tasks containing a specific keyword.
- `bye`: Exit Dude.

## Examples:

- To add a to-do task: `todo Buy groceries`
- To add a deadline task: `deadline Submit report /by 2023-12-31`
- To add an event task: `event Team meeting /from 2023-09-30 /to 2023-10-01`
- To mark a task as done: `mark 1`
- To delete a task: `delete 2`
- To find tasks containing a keyword: `find book`

Remember to replace `<description>`, `<due_date>`, `<start_date>`, `<end_date>`, `<task_index>`, and `<keyword>` with your specific task details.

## Conclusion

You're now ready to start using Dude to manage your tasks efficiently. If you have any questions or encounter issues, feel free to reach out to us. Dude is here to make task management a breeze!

Happy tasking!
62 changes: 46 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,59 @@
# User Guide
# Dude Chatbot User Guide

## Features
Welcome to Dude, your trusty task management chatbot. Dude helps you stay organized by keeping track of your tasks, whether they're to-dos, deadlines, or events. This user guide will provide you with the essential information to make the most of Dude's features.

### Feature-ABC

Description of the feature.
## Getting Started

### Feature-XYZ
To get started with Dude, follow these steps:

Description of the feature.
1. Ensure you have Java Development Kit (JDK) 11 installed on your computer.
2. Make sure you have the latest version of IntelliJ IDEA installed.
3. Clone or download the Dude project repository.

## Usage
## Setting Up Dude in IntelliJ IDEA

### `Keyword` - Describe action
1. Open IntelliJ IDEA.
2. If you have an existing project open, close it.
3. Click on "File" > "Open" and select the Dude project directory.
4. Configure the project to use JDK 11:
- Click on "File" > "Project Structure."
- Under "Project," set the "Project SDK" to JDK 11.
- Set the "Project language level" to "SDK default."

Describe the action and its outcome.
## Running Dude

Example of usage:
1. Locate the `Dude.java` file in the `src/main/java` directory of the Dude project.
2. Right-click on `Dude.java` and select "Run Dude.main()".
3. If everything is set up correctly, Dude will start, and you'll see a greeting message.

`keyword (optional arguments)`
## Using Dude

Expected outcome:
Dude understands various commands to manage your tasks. Here are some essential commands:

Description of the outcome.
- `list`: List all tasks in your task list.
- `todo <description>`: Add a to-do task.
- `deadline <description> /by <due_date>`: Add a deadline task.
- `event <description> /from <start_date> /to <end_date>`: Add an event task.
- `mark <task_index>`: Mark a task as done.
- `unmark <task_index>`: Mark a task as not done.
- `delete <task_index>`: Delete a task from the list.
- `find <keyword>`: Find tasks containing a specific keyword.
- `bye`: Exit Dude.

```
expected output
```
## Examples:

- To add a to-do task: `todo Buy groceries`
- To add a deadline task: `deadline Submit report /by 2023-12-31`
- To add an event task: `event Team meeting /from 2023-09-30 /to 2023-10-01`
- To mark a task as done: `mark 1`
- To delete a task: `delete 2`
- To find tasks containing a keyword: `find book`

Remember to replace `<description>`, `<due_date>`, `<start_date>`, `<end_date>`, `<task_index>`, and `<keyword>` with your specific task details.

## Conclusion

You're now ready to start using Dude to manage your tasks efficiently. If you have any questions or encounter issues, feel free to reach out to us. Dude is here to make task management a breeze!

Happy tasking!
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: dude.Dude

56 changes: 56 additions & 0 deletions src/dude/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package dude;

/**
* The `Deadline` class represents a task with a deadline, which has a description and a due date (by).
* It extends the `Task` class and provides additional fields and methods specific to deadline tasks.
*/
public class Deadline extends Task {
private String by;

/**
* Constructs a new `Deadline` task with the specified description and due date (by).
*
* @param description The description of the deadline task.
* @param by The due date of the deadline task.
*/
public Deadline(String description, String by) {
super(description);
this.by = by;
this.type = "[D]";
}

/**
* Converts the deadline task to a formatted string for saving to a file.
*
* @return A string representation of the deadline task in file format.
*/
@Override
public String toFileFormat() {
return super.toFileFormat() + " | " + by;
}

/**
* Creates a `Deadline` object from a string in file format.
*
* @param fileString A string containing the deadline task details in file format.
* @return A `Deadline` object parsed from the file string.
*/
public static Deadline fromFileFormat(String fileString) {
String[] parts = fileString.split("\\s\\|\\s");
Deadline deadline = new Deadline(parts[2], parts[3]);
if (parts[1].equals("1")) {
deadline.setDone(deadline.isDone);
}
return deadline;
}

/**
* Generates a string representation of the deadline task, including its description and due date.
*
* @return A string representing the deadline task.
*/
@Override
public String toString() {
return super.toString() + " (by: " + by + ")";
}
}
57 changes: 57 additions & 0 deletions src/dude/Dude.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package dude;

import java.util.ArrayList;

/**
* The `Dude` class represents the main application class for the Dude task manager.
* It initializes the user interface, storage, and task list, and manages the main
* execution flow of the program.
*/
public class Dude {
private Storage storage;
private TaskList tasks;
private Ui ui;

/**
* Constructs a new `Dude` instance with the specified file path.
*
* @param filePath The file path for storing task data.
*/
public Dude(String filePath) {
ui = new Ui();
storage = new Storage(filePath);
try {
tasks = new TaskList(storage.loadFromFile(), storage, ui);
} catch (Exception e) {
// Display a generic error message or log the exception details
ui.showMessage("Error loading tasks from file: " + e.getMessage());
tasks = new TaskList(new ArrayList<>(), storage, ui);
}
}

/**
* Runs the Dude application, displaying a greeting message and entering an
* infinite loop to process user commands until the user exits the program.
*/
public void run() {
ui.showGreeting();
while (true) { // Infinite loop since exit is handled in the Parser
try {
String fullCommand = ui.readCommand();
Parser.parse(fullCommand, tasks, ui, storage);
} catch (DudeException e) {
ui.showError(e.getMessage());
}
}
}

/**
* The entry point of the Dude application. Creates a new `Dude` instance with
* a specified data file path and starts the application by calling the `run` method.
*
* @param args Command-line arguments (not used in this application).
*/
public static void main(String[] args) {
new Dude("dude.txt").run();
}
}
17 changes: 17 additions & 0 deletions src/dude/DudeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dude;

/**
* The `DudeException` class represents a custom exception that can be thrown to handle
* exceptional situations within the Dude application.
*/
public class DudeException extends Exception {

/**
* Constructs a new `DudeException` with the specified error message.
*
* @param message The error message associated with the exception.
*/
public DudeException(String message) {
super(message);
}
}
59 changes: 59 additions & 0 deletions src/dude/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package dude;

/**
* The `Event` class represents an event task that has a description, start time (from), and end time (to).
* It extends the `Task` class and provides additional fields and methods specific to event tasks.
*/
public class Event extends Task {
private String from;
private String to;

/**
* Constructs a new `Event` task with the specified description, start time (from), and end time (to).
*
* @param description The description of the event task.
* @param from The start time of the event.
* @param to The end time of the event.
*/
public Event(String description, String from, String to) {
super(description);
this.from = from;
this.to = to;
this.type = "[E]";
}

/**
* Converts the event task to a formatted string for saving to a file.
*
* @return A string representation of the event task in file format.
*/
@Override
public String toFileFormat() {
return super.toFileFormat() + " | " + from + " | " + to;
}

/**
* Creates an `Event` object from a string in file format.
*
* @param fileString A string containing the event task details in file format.
* @return An `Event` object parsed from the file string.
*/
public static Event fromFileFormat(String fileString) {
String[] parts = fileString.split("\\s\\|\\s");
Event event = new Event(parts[2], parts[3], parts[4]);
if (parts[1].equals("1")) {
event.setDone(event.isDone);
}
return event;
}

/**
* Generates a string representation of the event task, including its description and time frame.
*
* @return A string representing the event task.
*/
@Override
public String toString() {
return super.toString() + " (from: " + from + " to: " + to + ")";
}
}
Loading