-
Notifications
You must be signed in to change notification settings - Fork 114
[Liu Hao] ip #115
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
Open
AaronZZ10
wants to merge
36
commits into
nus-cs2113-AY2425S1:master
Choose a base branch
from
AaronZZ10:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Liu Hao] ip #115
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
7305458
Level-0
67c4b99
Level-1
6e88ddf
Level-2
124e27b
Level-3
7eafffd
Level-4
ce8c990
Level-4
ca53856
Level-4
bbbc899
Level-2
a4c13d6
Level-3
bf97069
Level-4
33131f8
A-CodeQuality
69fba63
fixed format
88b3907
code quality
37af72d
ui-test
af7427e
ui-test
7c8bbb9
exemption and list class
fd03a78
packages
cf29cf0
delete
d2a22fd
save and load
9d08a78
save and load
29ba5f7
jar
b33d960
date and time
27ac37b
find function
d9d5498
oop
87c7068
method headers
a82c87a
fixed showWelcome() and update readme.md
2d1fff3
add clear function
49f8cfa
fix jar
c8afe18
fix file path
34bd20e
change readme
f95bd41
Merge pull request #1 from AaronZZ10/feature1
AaronZZ10 a708d72
fixed exit with bye at very beginning
1d8d7a2
Merge remote-tracking branch 'origin/master'
4f19c4a
update readme.md
b083a0a
fix mark unmark exception, create logo, and changed format of date
66b8af4
update readme.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,126 @@ | ||
| # Duke project template | ||
| # Taylor Task Management Chatbot | ||
|
|
||
| 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. | ||
| Welcome to **Taylor**, a simple Java-based task management chatbot designed to help you organize your tasks effectively. Taylor can handle various task types such as Todos, Deadlines, and Events. This guide will walk you through setting up and using Taylor to manage your tasks. | ||
|
|
||
| ## 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. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first). | ||
| 2. 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> | ||
| 2. Select the project directory, and click `OK`. | ||
| 3. If there are any further prompts, accept the defaults. | ||
| 3. Configure the project to use **JDK 17** (not other versions) as explained in [this guide](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: | ||
| 4. After that, locate the `src/main/java/Taylor.java` file, right-click it, and choose `Run Taylor.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the following as the output: | ||
| ``` | ||
| Hello from | ||
| ____ _ | ||
| | _ \ _ _| | _____ | ||
| | | | | | | | |/ / _ \ | ||
| | |_| | |_| | < __/ | ||
| |____/ \__,_|_|\_\___| | ||
| Hello! I'm Taylor.command.Taylor | ||
| What can I do for you? | ||
| ``` | ||
|
|
||
| ## Using Taylor | ||
|
|
||
| Taylor is a simple chatbot that allows you to add, list, mark, unmark, and delete tasks. Below is a list of commands and features to help you get started. | ||
|
|
||
| ### Available Commands | ||
|
|
||
| 1. **Add a Todo**: | ||
| - Adds a todo task to your list. | ||
| - **Command**: `todo <task description>` | ||
| - **Example**: `todo read a book` | ||
|
|
||
| 2. **Add an Event**: | ||
| - Adds an event task with a specific start and end time. | ||
| - **Command**: `event <description> /from <start time> /to <end time>` | ||
| - **Example**: `event project meeting /from Aug 1st 2pm /to Aug 1st 4pm` | ||
|
|
||
| 3. **Add a Deadline**: | ||
| - Adds a task with a specific deadline. | ||
| - **Command**: `deadline <description> /by <date>` | ||
| - **Example**: `deadline submit report /by 2024-12-01` | ||
|
|
||
| 4. **List All Tasks**: | ||
| - Displays all tasks currently in your list. | ||
| - **Command**: `list` or `ls` | ||
|
|
||
| 5. **Mark a Task as Completed**: | ||
| - Marks a task as completed. | ||
| - **Command**: `mark <task number>` | ||
| - **Example**: `mark 2` | ||
|
|
||
| 6. **Unmark a Task**: | ||
| - Marks a task as not completed. | ||
| - **Command**: `unmark <task number>` | ||
| - **Example**: `unmark 2` | ||
|
|
||
| 7. **Delete a Task**: | ||
| - Deletes a task from the list. | ||
| - **Command**: `delete <task number>` | ||
| - **Example**: `delete 3` | ||
|
|
||
| 8. **Find a Task**: | ||
| - Finds tasks that match a specific keyword. | ||
| - **Command**: `find <keyword>` | ||
| - **Example**: `find book` | ||
|
|
||
| 9. **Clear all tasks**: | ||
| - Clear all the tasks in the list | ||
| - **Command**: `clear` followed by `yes` or `y` or `ok` | ||
| - **Example**: `clear` -> `y` | ||
|
|
||
| 10. **Exit the Program**: | ||
| - Exits the chatbot. | ||
| - **Command**: `bye` | ||
|
|
||
| ### Task Types | ||
|
|
||
| - **Todo**: A simple task that only contains a description (e.g., "read a book"). | ||
| - **Deadline**: A task with a deadline (e.g., "submit report by 2024-12-01"). | ||
| - **Event**: A task that occurs over a specific time period (e.g., "meeting from 2pm to 4pm"). | ||
|
|
||
| ### Task Management | ||
|
|
||
| - Tasks can be marked as completed or not completed. | ||
| - You can delete tasks from the list when they are no longer needed. | ||
| - The chatbot saves your tasks automatically, so they will be available the next time you start the program. | ||
|
|
||
| ### Example Interaction | ||
|
|
||
| ``` | ||
| Hello! I'm Taylor | ||
| What can I do for you? | ||
|
|
||
| todo read book | ||
| Got it. I've added this task: | ||
| [T][ ] read book | ||
|
|
||
| deadline submit report /by 2024-12-01 | ||
| Got it. I've added this task: | ||
| [D][ ] submit report (by: Dec 1 2024) | ||
|
|
||
| list | ||
| Here are the tasks in your list: | ||
| 1. [T][ ] read book | ||
| 2. [D][ ] submit report (by: Dec 1 2024) | ||
|
|
||
| mark 1 | ||
| Nice! I've marked this task as done: | ||
| [T][X] read book | ||
|
|
||
| bye | ||
| Bye. Hope to see you again soon! | ||
| ``` | ||
|
|
||
| With these commands, you'll be able to manage your tasks effectively using Taylor! | ||
|
|
||
| ### Troubleshooting | ||
|
|
||
| If you encounter any issues, make sure: | ||
| - You are using JDK 17. | ||
| - The project is set up correctly in IntelliJ. | ||
| - You followed the command format as outlined above. | ||
|
|
||
| --- | ||
|
|
||
| This guide should provide you with enough information to get started with Taylor. If you have further questions, feel free to refer to the code comments or reach out for additional help! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Manifest-Version: 1.0 | ||
| Main-Class: Taylor.command.Taylor | ||
|
|
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package Taylor.command; | ||
|
|
||
| import Taylor.task.TaskList; | ||
| import Taylor.task.Task; | ||
| import Taylor.task.Todo; | ||
| import Taylor.task.Deadline; | ||
| import Taylor.task.Event; | ||
|
|
||
| import java.io.*; | ||
| import java.util.ArrayList; | ||
|
|
||
| /** | ||
| * Represents the storage for the Taylor task management application. | ||
| * The Storage class handles reading and writing tasks to a file. | ||
| */ | ||
| public class Storage { | ||
| private final String filePath; | ||
|
|
||
| /** | ||
| * Constructs a new Storage object with the specified file path. | ||
| * | ||
| * @param filePath The path to the file where tasks will be saved and loaded from. | ||
| */ | ||
| public Storage(String filePath) { | ||
| this.filePath = filePath; | ||
| } | ||
|
|
||
| /** | ||
| * Loads tasks from the file at the specified file path. Tasks are parsed from | ||
| * the file and stored in an ArrayList. | ||
| * | ||
| * @return An ArrayList of Task objects loaded from the file. | ||
| * @throws IOException If an I/O error occurs while reading the file. | ||
| * @throws TaylorException If the file contains an unknown task type. | ||
| */ | ||
| public ArrayList<Task> load() throws IOException, TaylorException { | ||
| File file = new File(filePath); | ||
| ArrayList<Task> tasks = new ArrayList<>(); | ||
| if (file.exists()) { | ||
| BufferedReader reader = new BufferedReader(new FileReader(file)); | ||
| String line = reader.readLine(); | ||
|
|
||
| // Read each line from the file and parse it into a task | ||
| while (line != null) { | ||
| String[] parts = line.split(" \\| "); | ||
| String taskType = parts[0].trim(); | ||
| boolean isCompleted = parts[1].trim().equals("1"); | ||
| String description = parts[2].trim(); | ||
|
|
||
| switch (taskType) { | ||
| case "T" -> tasks.add(new Todo(description, isCompleted)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the structure of switch statements using breaks and colons, instead of arrow. |
||
| case "D" -> tasks.add(new Deadline(description, isCompleted, parts[3].trim())); | ||
| case "E" -> { | ||
| String[] time = parts[3].split("-"); | ||
| String from = time[0].trim(); | ||
| String to = time[1].trim(); | ||
| tasks.add(new Event(description, isCompleted, from, to)); | ||
| } | ||
| default -> throw new TaylorException("Unknown task type in file"); | ||
| } | ||
| line = reader.readLine(); | ||
| } | ||
| reader.close(); | ||
| } | ||
| return tasks; | ||
| } | ||
|
|
||
| /** | ||
| * Saves the tasks to the file at the specified file path. Each task is serialized | ||
| * into a string format suitable for storage. | ||
| * | ||
| * @param tasks The TaskList containing the tasks to be saved. | ||
| * @throws IOException If an I/O error occurs while writing to the file. | ||
| */ | ||
| public void save(TaskList tasks) throws IOException { | ||
| File file = new File(filePath); | ||
| if (file.getParentFile().mkdirs()) { | ||
| System.out.println("Directory created"); | ||
| } | ||
| FileWriter writer = new FileWriter(file); | ||
| writer.write(tasks.write()); | ||
| writer.close(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps provide a better descriptive name for the method?
This applies to the method names in this file such as "save" as well.