-
Notifications
You must be signed in to change notification settings - Fork 191
[Yap Joon Siong] iP #186
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
yapjoonsiong
wants to merge
27
commits into
nus-cs2113-AY2122S1:master
Choose a base branch
from
yapjoonsiong: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
[Yap Joon Siong] iP #186
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3d64ed6
Implement an initial skeletal version of the Duke that simply greets …
yapitsmejs daaef83
Implement a skeletal version of Duke that starts by greeting the user…
yapitsmejs 4014037
Add the ability to store whatever text entered by the user and displa…
yapitsmejs a81bc62
Add the ability to mark tasks as done.
yapitsmejs cd250ac
Separate Task and Information classes
yapitsmejs aee5770
Add support for tracking three types of tasks. Change program persona…
yapitsmejs 7bdb999
Correct spacing in response message. update ui-test input and expecte…
yapitsmejs b2ef7be
Teach Jarvis to deal with errors such as incorrect inputs entered by …
yapitsmejs d8af22f
Revert "Teach Jarvis to deal with errors such as incorrect inputs ent…
yapitsmejs b937e10
Teach Duke to deal with errors such as incorrect inputs entered by th…
yapitsmejs b1afac4
Merge branch 'branch-Level-5'
yapitsmejs f083420
Add support for deleting tasks from the list.
yapitsmejs 3477bc0
Save the tasks in the hard disk automatically whenever the task list …
yapitsmejs 2aca76a
Merge branch 'branch-Level-6'
yapitsmejs c729df8
Merge branch 'branch-Level-7'
yapitsmejs e0aa491
Resolved merge conflicts
yapitsmejs 3a2629b
Give users a way to find a task by searching for a keyword. Refactor …
yapitsmejs 123b746
Merge branch 'branch-Level-9'
yapitsmejs 6e3a937
Add JavaDoc comments to the code.
yapitsmejs d4638a8
Merge branch 'branch-A-JavaDoc'
yapitsmejs 4160b4a
Clean up Code. Fix bugs. Updated README.
yapitsmejs e4cb511
Update README.
yapitsmejs aae0f49
Update README
yapitsmejs dc02a7c
Update README
yapitsmejs c9c6b35
Update README
yapitsmejs 43757a3
Update README
yapitsmejs 685cadf
Fixed bugs. Fixed coding standards.
yapitsmejs 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
Empty file.
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,29 +1,135 @@ | ||
| # User Guide | ||
|
|
||
| ## Features | ||
| Duke is a **desktop app for managing your tasks, optimized for use via a Command Line Interface** (CLI). If you can type | ||
| fast, Duke can get your task management done faster than traditional GUI apps. It is the perfect app for busy people! | ||
|
|
||
| ### Feature-ABC | ||
| 1. Features | ||
| 1. Adding a todo: `todo` | ||
| 2. Adding an event: `event` | ||
| 3. Adding a deadline: `deadline` | ||
| 4. List all tasks: `list` | ||
| 5. Marking a task as done: `done` | ||
| 6. Deleting a task: `delete` | ||
| 7. Finding a task with a keyword: `find` | ||
| 2. Command Summary | ||
|
|
||
| Description of the feature. | ||
| ## Features | ||
|
|
||
| ### Feature-XYZ | ||
|
|
||
| Description of the feature. | ||
| **Command format:** | ||
|
|
||
| ## Usage | ||
|
|
||
| ### `Keyword` - Describe action | ||
| * Words in `UPPER_CASE` are the parameters to be supplied by the user. (eg. `todo` `TASK_DESCRIPTION`, `TASK_DESCRIPTION` is | ||
| the description of the | ||
| task supplied by the user.) | ||
| * Extraneous parameters for commands that do not take in parameters (such as `list` and `bye`) is not acceptable. | ||
| e.g. if the command specifies `list 123`, there will be an error. | ||
|
|
||
| Describe the action and its outcome. | ||
|
|
||
| Example of usage: | ||
| **Adding a todo** | ||
|
|
||
| `keyword (optional arguments)` | ||
|
|
||
| Expected outcome: | ||
| Adds a todo to your list of tasks. | ||
|
|
||
| Description of the outcome. | ||
| format: `todo TASK_DESCRIPTION` | ||
|
|
||
| ``` | ||
| expected output | ||
| ``` | ||
| Example input: | ||
|
|
||
| `todo lunch` | ||
|
|
||
| `todo deliver parcel` | ||
|
|
||
|
|
||
| **Adding an Event** | ||
|
|
||
|
|
||
| Adds an event to your list of tasks. | ||
|
|
||
| format: `event TASK_DESCRIPTION /at TIME_DESCRIPTION` | ||
|
|
||
| Example input: | ||
|
|
||
| `event family dinner /at sunday` | ||
|
|
||
| `event concert /at friday night` | ||
|
|
||
|
|
||
| **Adding a Deadline** | ||
|
|
||
|
|
||
| Adds a deadline to your list of tasks. | ||
|
|
||
| format: `deadline TASK_DESCRIPTION /by TIME_DESCRIPTION` | ||
|
|
||
| Example input: | ||
|
|
||
| `deadline assignment /by sunday night` | ||
|
|
||
| `deadline complete report /by monday` | ||
|
|
||
|
|
||
| **Listing Tasks** | ||
|
|
||
|
|
||
| Shows a list of all tasks. | ||
|
|
||
| Format: `list` | ||
|
|
||
|
|
||
| **Mark Task as Done** | ||
|
|
||
|
|
||
| Marks the task with the corresponding number in the list as done. | ||
|
|
||
| Format: `done TASK_NUMBER` | ||
|
|
||
| Example input: | ||
|
|
||
| `done 1` | ||
|
|
||
|
|
||
| **Delete Task** | ||
|
|
||
|
|
||
| Deletes the task with the corresponding number in the list. | ||
|
|
||
| Format: `delete TASK_NUMBER` | ||
|
|
||
| Example input: | ||
|
|
||
| `delete 1` | ||
|
|
||
|
|
||
| **Find Task** | ||
|
|
||
|
|
||
| Finds all tasks containing user input keyword in their descriptions | ||
|
|
||
| Format: `find KEYWORD` | ||
|
|
||
| Example input: | ||
|
|
||
| `find lunch` | ||
|
|
||
|
|
||
| **Bye** | ||
|
|
||
|
|
||
| Exits the program. | ||
|
|
||
| Format: `bye` | ||
|
|
||
|
|
||
| ## Command Summary | ||
|
|
||
|
|
||
| Action | Format, Examples | ||
| ------ | ---------------- | ||
| todo | `todo TASK_DESCRIPTION` eg. `todo deliver parcel` | ||
| event | `event TASK_DESCRIPTION /at TIME_DESCRIPTION` eg. `event concert /at friday night` | ||
| deadline | `deadline TASK_DESCRIPTION /by TIME_DESCRIPTION` eg. `deadline assignment /by sunday night` | ||
| list | `list` | ||
| done | `done TASK_NUMBER` eg. `done 1` | ||
| delete | `delete TASK_NUMBER` eg. `delete 1` | ||
| find | `find KEYWORD` eg. `find lunch` | ||
| bye | `bye` |
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,26 @@ | ||
| import java.io.IOException; | ||
|
|
||
| public class AddTask extends Command{ | ||
| private Task task; | ||
| private Tasks tasks; | ||
| private Ui ui; | ||
| private Storage storage; | ||
| /** | ||
| * Constructor for command for user to add a new task. Task can be either a normal task, an Event or a Deadline | ||
| * @param tasks list of existing tasks for task to be added to | ||
| * @param task Task to be added. Either be a normal task, an Event or a Deadline | ||
| * @param ui Handles interaction with the user | ||
| * @param storage updates "data/duke.txt" | ||
| */ | ||
| public AddTask(Tasks tasks, Task task, Ui ui, Storage storage) { | ||
| this.tasks = tasks; | ||
| this.task = task; | ||
| this.ui = ui; | ||
| this.storage = storage; | ||
| } | ||
| public void execute() throws IOException { | ||
| tasks.add(task); | ||
| ui.add(task, tasks); | ||
| storage.writeToFile(tasks); | ||
| } | ||
| } |
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,15 @@ | ||
| public class Bye extends Command { | ||
| private Ui ui; | ||
|
|
||
| /** | ||
| * Constructor when user wants to close the application. | ||
| * @param ui Handles interaction with the user. | ||
| */ | ||
| public Bye(Ui ui) { | ||
| this.ui = ui; | ||
| } | ||
| public boolean isExit() { | ||
| ui.exit(); | ||
| return true; | ||
| } | ||
| } |
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,13 @@ | ||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Represents a command made by the user. | ||
| */ | ||
| public abstract class Command { | ||
| public void execute() throws IOException { | ||
|
|
||
| } | ||
| public boolean isExit() { | ||
| return false; | ||
| } | ||
| } |
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,30 @@ | ||
| public class Deadline extends Task{ | ||
| protected String by; | ||
|
|
||
| /** | ||
| * Represents a Deadline added by the user. | ||
| * | ||
| * @param description Description of task with a deadline. | ||
| * @param by Description of the deadline of the task | ||
| */ | ||
| public Deadline(String description, String by) { | ||
| super(description); | ||
| this.by = by; | ||
| } | ||
|
|
||
| public String getTime() { | ||
| return this.by; | ||
| } | ||
|
|
||
| public void setBy(String by) { | ||
| this.by = by; | ||
| } | ||
|
|
||
| public String getType() { | ||
| return "D"; | ||
| } | ||
|
|
||
| public String toString() { | ||
| return "[D]" + super.getStatus() + super.getDescription() + " (by:" + by + ")"; | ||
| } | ||
| } |
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,28 @@ | ||
| import java.io.IOException; | ||
|
|
||
| public class Delete extends Command{ | ||
| private Tasks tasks; | ||
| private Task task; | ||
| private Ui ui; | ||
| private Storage storage; | ||
|
|
||
| /** | ||
| * Constructor for command for user to delete a task from the list. | ||
| * @param tasks list of all existing tasks | ||
| * @param index index of task to be deleted | ||
| * @param ui Handles interaction with user. | ||
| * @param storage updates "data/duke.txt" file | ||
| */ | ||
| public Delete(Tasks tasks, int index, Ui ui, Storage storage) { | ||
| this.tasks = tasks; | ||
| this.task = tasks.get(index); | ||
| this.ui = ui; | ||
| this.storage = storage; | ||
| } | ||
|
|
||
| public void execute() throws IOException { | ||
| ui.delete(task, tasks); | ||
| tasks.delete(task); | ||
| storage.writeToFile(tasks); | ||
| } | ||
| } |
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,29 @@ | ||
| import java.io.IOException; | ||
|
|
||
| public class Done extends Command { | ||
| private Tasks tasks; | ||
| private Task task; | ||
| private Ui ui; | ||
| private Storage storage; | ||
|
|
||
| /** | ||
| * Constructor for command when the user marks a task as done. | ||
| * @param tasks List of all existing tasks. | ||
| * @param index Index of task to be marked done | ||
| * @param ui Handles interaction with user. | ||
| * @param storage updates "data/duke.txt" file | ||
| */ | ||
| public Done(Tasks tasks, int index, Ui ui, Storage storage) { | ||
| tasks.get(index).markComplete(); | ||
| this.tasks = tasks; | ||
| this.task = tasks.get(index); | ||
| this.ui = ui; | ||
| this.storage = storage; | ||
| } | ||
|
|
||
| public void execute() throws IOException { | ||
| ui.done(task, tasks); | ||
| task.markComplete(); | ||
| storage.writeToFile(tasks); | ||
| } | ||
| } |
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,10 +1,53 @@ | ||
| import java.util.Random; | ||
| import java.util.Scanner; | ||
| import java.io.File; | ||
| import java.io.FileWriter; | ||
| import java.io.IOException; | ||
| import java.io.FileNotFoundException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Paths; | ||
|
|
||
| /** | ||
| * Duke is a friendly note-taking bot. | ||
| * Duke keeps track of all your tasks in a reader-friendly format, | ||
| * even after you close the application | ||
| * | ||
| * @author Yap Joon Siong | ||
| * @version 1.0 | ||
| * Cool @since 2021-09-28 | ||
| */ | ||
| public class Duke { | ||
| public static void main(String[] args) { | ||
| String logo = " ____ _ \n" | ||
| + "| _ \\ _ _| | _____ \n" | ||
| + "| | | | | | | |/ / _ \\\n" | ||
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
| private static File save; | ||
| private Storage storage; | ||
| private Tasks tasks = new Tasks(); | ||
| private Ui ui; | ||
|
|
||
| private Duke(String filePath) throws IOException { | ||
| ui = new Ui(); | ||
| File directory = new File ("data"); | ||
| if (!directory.exists()) { | ||
| directory.mkdir(); | ||
| } | ||
| storage = new Storage(filePath); | ||
| tasks = storage.load(); | ||
| } | ||
|
|
||
| private void run() throws IOException { | ||
| ui.greet(); | ||
| boolean isExit = false; | ||
| while (!isExit) { | ||
| try { | ||
| String fullCommand = ui.readCommand(); | ||
| Command c = Parser.parse(fullCommand, tasks, ui, storage); | ||
| c.execute(); | ||
| isExit = c.isExit(); | ||
| } catch (DukeException e) { | ||
| System.out.println(e.getMessage()); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static void main(String[] args) throws IOException { | ||
| new Duke("data/duke.txt").run(); | ||
| } | ||
| } | ||
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,5 @@ | ||
| public class DukeException extends Exception { | ||
| public DukeException(String message) { | ||
| super(message); | ||
| } | ||
| } |
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,27 @@ | ||
| public class Event extends Task{ | ||
| protected String at; | ||
|
|
||
| /** | ||
| * Represents an Event made by the user. | ||
| * | ||
| * @param description Description of Event. | ||
| * @param at Description of when the event will take place. | ||
| */ | ||
| public Event (String description, String at) { | ||
| super(description); | ||
| this.at = at; | ||
| } | ||
|
|
||
| public void setAt(String at) { | ||
| this.at = at; | ||
| } | ||
| public String getTime() { | ||
| return this.at; | ||
| } | ||
| public String getType() { | ||
| return "E"; | ||
| } | ||
| public String toString() { | ||
| return "[E]" + super.getStatus() + super.getDescription() + " (at:" + at + ")"; | ||
| } | ||
| } |
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.
Generally, you could consider adding more comments to describe what your methods or classes are doing.