-
Notifications
You must be signed in to change notification settings - Fork 82
[Tai Kah Kiang] iP #70
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
kktai1512
wants to merge
42
commits into
nus-cs2113-AY2122S2:master
Choose a base branch
from
kktai1512: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
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
e1b96e2
add greeting
kktai1512 9a88290
refactored level_0
kktai1512 f35f63d
add greet echo exit, and abstracted out print with divider
kktai1512 ca00879
add list ability using arraylist
kktai1512 212f360
add toggle complete
kktai1512 47cce8f
add todo, deadline and event subclass (level 4)
kktai1512 85f8d73
add automated testing
kktai1512 bebd84d
abstract run function from main, clean up code, fix event toString typo
kktai1512 66cb637
abstract out task related things to TaskManager class
kktai1512 ff54efb
add error handling
kktai1512 1bfe6b6
add DukeException class
kktai1512 1da8e96
Merge branch 'branch-Level-5'
kktai1512 2e14be2
add to packages
kktai1512 38c3895
Merge branch 'add-package'
kktai1512 0a80df8
add delete task function
kktai1512 4732cce
add file writer and reader
kktai1512 676c634
complete filereader
kktai1512 76c50b1
merge level 7
kktai1512 63ce6a0
add more oop- parser, ui, command, storage
kktai1512 f64e5e9
change deadline of Deadline to by, time of Event to on
kktai1512 6fdb78a
add date/time
kktai1512 f304d13
add find functionality
kktai1512 318d046
add date and time
kktai1512 c9546db
Merge pull request #1 from kktai1512/branch-Level-8
kktai1512 4c0e6d8
merge from master
kktai1512 b6adc88
Merge pull request #2 from kktai1512/branch-Level-9
kktai1512 921bb7f
add javadoc for taskmanager and storage
kktai1512 550f812
Update README.md
kktai1512 04944b6
add more javadocs
kktai1512 b7d0ed6
change to autosave everytine tasks has changed
kktai1512 b1e1f7e
change such that task doesnt accept nameless / wrong name
kktai1512 52e2312
check for style
kktai1512 05026dc
check for style
kktai1512 d4a94ac
remove checkstyle
kktai1512 8579519
Merge pull request #3 from kktai1512/branch-A-JavaDoc
kktai1512 d6bef1e
allow non alphanumeric name, disallow / in taskName
kktai1512 424ec24
allow non alphanumeric name, disallow / in taskName
kktai1512 75b13f8
Update README.md
kktai1512 816230c
change readme.md
kktai1512 7ffb9af
change readme.md
kktai1512 b2c7657
Update README.md
kktai1512 c170780
Update README.md
kktai1512 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 |
|---|---|---|
|
|
@@ -15,3 +15,5 @@ bin/ | |
|
|
||
| /text-ui-test/ACTUAL.txt | ||
| text-ui-test/EXPECTED-UNIX.TXT | ||
|
|
||
| checkstyle.xml | ||
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,2 @@ | ||
| 1. [T][ ] ` | ||
| 2. [D][ ] ` (by: 99) |
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
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,141 @@ | ||
| # User Guide | ||
|
|
||
| ## Features | ||
|
|
||
| ### Feature-ABC | ||
| # Welcome to Duke! | ||
| Duke is a CLI-based todo application. | ||
| # Getting started | ||
| After running the JAR file, an output file named "Duke.txt" will be created in the same directory of the JAR. Output will be saved into the file before the program exits, and the file will be reread the next time Duke runs. | ||
|
|
||
| Description of the feature. | ||
| To run the file, from the terminal, go to the same directory as your Duke.jar file, and run the command `java -jar Duke.jar` | ||
|
|
||
| ### Feature-XYZ | ||
|
|
||
| Description of the feature. | ||
| # Features and usage | ||
| | Notation | Meaning | | ||
| |--|--| | ||
| | [T] | todo | | ||
| | [D] | deadline| | ||
| | [E] | event | | ||
| | [ ] | incomplete task | ||
| | [X] | completed task | ||
|
|
||
| ## Usage | ||
|
|
||
| ### `Keyword` - Describe action | ||
|
|
||
| Describe the action and its outcome. | ||
|
|
||
| Example of usage: | ||
| ## Add | ||
| There are three types of tasks to be added. Namely, todo, deadline and event. | ||
| ### Todo | ||
|
|
||
| `keyword (optional arguments)` | ||
| To add a todo, command should be typed in the format | ||
| `todo (taskname)` | ||
| Example of a valid input: | ||
| `todo get groceries` | ||
|
|
||
| Expected outcome: | ||
| Sample usage: | ||
|
|
||
| Description of the outcome. | ||
| todo buy groceries | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [T][ ] buy groceries | ||
| Now you have 1 task in the list. | ||
| ____________________________________________________________ | ||
|
|
||
|
|
||
|
|
||
| ### Event / Deadline | ||
|
|
||
| To add an event or a deadline, command should be typed in the format `event (taskname) /(dd-MM-yyyy HH:mm)` or | ||
| `event (taskname) /(additional info)` | ||
|
|
||
| :white_check_mark: Sample usage with valid input: | ||
|
|
||
|
|
||
| deadline cs2113t project /tomorrow | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [D][ ] cs2113t project (by: tomorrow) | ||
| Now you have 2 tasks in the list. | ||
| ____________________________________________________________ | ||
| event Mark's birthday party /07-03-2022 22:00 | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [E][ ] Mark's birthday party (on: Mar 07 2022 22:00) | ||
| Now you have 3 tasks in the list. | ||
| ____________________________________________________________ | ||
|
|
||
|
|
||
|
|
||
| :x: Example of a invalid input: | ||
|
|
||
| deadline hello / | ||
| event / | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ## List | ||
| To list all the tasks, simply type | ||
| `list` | ||
|
|
||
|
|
||
| Sample usage: | ||
|
|
||
| list | ||
| ____________________________________________________________ | ||
| 1. [T][ ] buy groceries | ||
| 2. [D][ ] cs2113t project (by: tomorrow) | ||
| 3. [E][ ] Mark's birthday party (on: Mar 07 2022 22:00) | ||
| ____________________________________________________________ | ||
|
|
||
| ## Delete | ||
| To delete a task, type in the command `delete (task number)` | ||
|
|
||
| Sample usage: | ||
|
|
||
| delete 2 | ||
| ____________________________________________________________ | ||
| Noted. I've removed this task: | ||
| [D][ ] cs2113t project (by: tomorrow) | ||
| Now you have 2 tasks in the list. | ||
| ____________________________________________________________ | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ## Mark/Unmark | ||
| To mark the task as completed, type in `mark (task number)`. | ||
| Similarly, type in `unmark (task number)` to mark the task as incomplete. | ||
|
|
||
| Sample usage: | ||
|
|
||
| mark 1 | ||
| ____________________________________________________________ | ||
| [T][X] buy groceries | ||
| ____________________________________________________________ | ||
| unmark 1 | ||
| ____________________________________________________________ | ||
| [T][ ] buy groceries | ||
| ____________________________________________________________ | ||
|
|
||
| ## Find | ||
| To find task(s) containing a specific keyword, type in `find (keyword)` | ||
|
|
||
| Sample usage: | ||
|
|
||
| find groceries | ||
| ____________________________________________________________ | ||
| Here are the matching tasks in your list: | ||
| 1. [T][ ] buy groceries | ||
| ____________________________________________________________ | ||
|
|
||
| ## Bye | ||
| To exit the program, simply type "bye". The program terminates and the current state of the tasks is saved into "Duke.txt". | ||
|
|
||
| Sample usage: | ||
|
|
||
| bye | ||
| ____________________________________________________________ | ||
| Bye. Hope to see you again soon! | ||
| ____________________________________________________________ | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ``` | ||
| expected output | ||
| ``` |
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,60 @@ | ||
| import java.io.IOException; | ||
|
|
||
| import duke.command.Command; | ||
| import duke.exception.DukeException; | ||
| import duke.parser.Parser; | ||
| import duke.storage.Storage; | ||
| import duke.task.TaskManager; | ||
| import duke.ui.Ui; | ||
|
|
||
| public class Duke { | ||
| public static void main(String[] args) { | ||
| String logo = " ____ _ \n" | ||
| + "| _ \\ _ _| | _____ \n" | ||
| + "| | | | | | | |/ / _ \\\n" | ||
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
|
|
||
| //fields | ||
| private TaskManager taskManager; | ||
| private Ui ui; | ||
| private Storage storage; | ||
|
|
||
| //methods | ||
|
|
||
| /** | ||
| * Creates a Duke Object | ||
| * @param filePath filePath of the input/output file | ||
| */ | ||
| public Duke(String filePath) { | ||
| ui = new Ui(); | ||
| storage = new Storage(filePath); | ||
| try { | ||
| taskManager = new TaskManager(); | ||
| taskManager.setTasks(storage.readFile()); | ||
| } catch (DukeException e) { | ||
| ui.showError(e); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Runs the main function | ||
| */ | ||
| public void run() { | ||
| ui.hello(); | ||
| boolean isExit = false; | ||
| while (!isExit) { | ||
| try { | ||
| String fullCommand = ui.readCommand(); | ||
| Command c = Parser.parse(fullCommand); | ||
| if (c != null) { | ||
| c.execute(taskManager, ui, storage); | ||
| isExit = c.isExit(); | ||
| } | ||
| } catch (DukeException e) { | ||
| ui.showError(e); | ||
| } | ||
| } | ||
|
|
||
| Ui.printWithDivider("Bye. Hope to see you again soon!"); | ||
|
|
||
| } | ||
|
|
||
| public static void main(String[] args) throws IOException { | ||
| new Duke ("./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,3 @@ | ||
| Manifest-Version: 1.0 | ||
| Main-Class: Duke | ||
|
|
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,31 @@ | ||
| package duke.command; | ||
|
|
||
| import duke.exception.DukeException; | ||
| import duke.storage.Storage; | ||
| import duke.task.TaskManager; | ||
| import duke.ui.Ui; | ||
|
|
||
| public class AddCommand extends Command { | ||
|
|
||
| private String commandType; | ||
| private String taskName; | ||
| private String addInfo; | ||
|
|
||
| /** | ||
| * Command for "add" operations (add todo, event or deadline) | ||
| * @param commandType todo, event or deadline | ||
| * @param taskName name of task | ||
| * @param addInfo additional information | ||
| */ | ||
| public AddCommand(String commandType, String taskName, String addInfo) { | ||
| this.taskName = taskName; | ||
| this.commandType = commandType; | ||
| this.addInfo = addInfo; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(TaskManager taskManager, Ui ui, Storage storage) throws DukeException { | ||
| taskManager.addTask(this.commandType, this.taskName, this.addInfo); | ||
| storage.writeFile(taskManager.toString()); | ||
| } | ||
| } |
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,9 @@ | ||
| package duke.command; | ||
|
|
||
| public class ByeCommand extends Command { | ||
|
|
||
| @Override | ||
| public boolean isExit() { | ||
| 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,24 @@ | ||
| package duke.command; | ||
| import duke.exception.DukeException; | ||
| import duke.storage.Storage; | ||
| import duke.task.TaskManager; | ||
| import duke.ui.Ui; | ||
|
|
||
| public abstract class Command { | ||
|
|
||
| /** | ||
| * Executes the command | ||
| * | ||
| * @param taskManager TaskManager instance in charge of calling the correct method | ||
| * @param ui Ui instance in charge to print | ||
| * @param storage Storage instance for writing files | ||
| * @throws DukeException | ||
| */ | ||
| public void execute(TaskManager taskManager, Ui ui, Storage storage) throws DukeException { | ||
|
|
||
| } | ||
|
|
||
| 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,21 @@ | ||
| package duke.command; | ||
|
|
||
| import duke.exception.DukeException; | ||
| import duke.storage.Storage; | ||
| import duke.task.TaskManager; | ||
| import duke.ui.Ui; | ||
|
|
||
| public class DeleteCommand extends Command { | ||
|
|
||
| private int taskNumber; | ||
| public DeleteCommand(int taskNumber) { | ||
| this.taskNumber = taskNumber; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(TaskManager taskManager, Ui ui, Storage storage) throws DukeException { | ||
| taskManager.deleteTask(this.taskNumber); | ||
| storage.writeFile(taskManager.toString()); | ||
|
|
||
| } | ||
| } |
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 @@ | ||
| package duke.command; | ||
|
|
||
| import duke.storage.Storage; | ||
| import duke.task.TaskManager; | ||
| import duke.ui.Ui; | ||
|
|
||
| public class FindCommand extends Command { | ||
|
|
||
| private String keyword; | ||
|
|
||
|
|
||
| public FindCommand(String keyword) { | ||
| this.keyword = keyword; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(TaskManager taskManager, Ui ui, Storage storage) { | ||
| TaskManager relatedTaskManager = taskManager.findTask(this.keyword); | ||
| if (relatedTaskManager.getNumOfTasks() == 0) { | ||
| Ui.printWithDivider("Sorry, task(s) containing the word " + this.keyword +" not found."); | ||
| } | ||
| else { | ||
| Ui.printWithDivider( "Here are the matching tasks in your list: \n" | ||
| + relatedTaskManager); | ||
| } | ||
|
|
||
| } | ||
| } |
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 @@ | ||
| package duke.command; | ||
|
|
||
| import duke.storage.Storage; | ||
| import duke.task.TaskManager; | ||
| import duke.ui.Ui; | ||
|
|
||
| public class ListCommand extends Command { | ||
|
|
||
| @Override | ||
| public void execute(TaskManager taskManager, Ui ui, Storage storage) { | ||
| Ui.printWithDivider(taskManager.toString()); | ||
| } | ||
| } |
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.
This comment is not very helpful in providing further explanation on how the variable is used. It can be omitted.