-
Notifications
You must be signed in to change notification settings - Fork 200
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
[ngyongjian] iP #208
Open
ngyongjian
wants to merge
29
commits into
nus-cs2113-AY2223S2:master
Choose a base branch
from
ngyongjian: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
[ngyongjian] iP #208
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
fff13bd
Level 1. Greet, Echo, Exit
ngyongjian d5c0add
Level 1. Greet, Echo, Exit
ngyongjian 900b481
Level 2. Add, List
ngyongjian 6b160da
Level 2
ngyongjian ef4b3fb
Level 3. Mark as Done
ngyongjian 443d336
Level 4. ToDos, Events, Deadlines
ngyongjian 49f3394
A-CodingStandard
ngyongjian 03e770e
A-CodeQuality
ngyongjian c010346
A-Exception
ngyongjian caa5969
Level 5. Handle Errors
ngyongjian 06d3da3
Organize into packages
ngyongjian 161d9d3
Level 6
ngyongjian 1672649
A-Collections
ngyongjian 8926248
Level-7
ngyongjian 2657473
undo Level-7
ngyongjian a31c6c2
branch-Level-7
ngyongjian 9f407e0
Level-7
ngyongjian cd97e4c
NumberOfTask debug
ngyongjian a178113
A-MoreOOP
ngyongjian 2c054d4
Level-9
ngyongjian 713b40a
Merge pull request #1 from ngyongjian/branch-Level-9
ngyongjian 10af1c0
add JavaDoc
ngyongjian 8aabdd8
Merge pull request #2 from ngyongjian/A-JavaDoc
ngyongjian f2ad465
Update README.md
ngyongjian ddc4626
Update README.md
ngyongjian 30670ce
Update README.md
ngyongjian 478a610
Update README.md
ngyongjian d35fc8f
Update README.md
ngyongjian f8ea312
Update README.md
ngyongjian 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 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,94 @@ | ||
# Duke project template | ||
# Duke - User Guide | ||
|
||
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. | ||
Duke is a personal task manager designed to help you stay organized and on top of your to-do list. With its automated features, Duke streamlines task management and can significantly improve your productivity. | ||
|
||
## Setting up in Intellij | ||
## Features | ||
|
||
Prerequisites: JDK 11, update Intellij to the most recent version. | ||
### 3 Types of Tasks | ||
- `todo` - Adds a simple todo task | ||
- `deadline` - Adds a deadline task with a due date | ||
- `event` - Adds an event task with a start time and an end time | ||
|
||
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 | ||
____ _ | ||
| _ \ _ _| | _____ | ||
| | | | | | | |/ / _ \ | ||
| |_| | |_| | < __/ | ||
|____/ \__,_|_|\_\___| | ||
### Other Functions | ||
- `mark` - Mark task as done | ||
- `unmark` - Mark task as not done | ||
- `list` - List all tasks | ||
- `find` - Find task(s) containing certain substring | ||
- `delete` - Delete a task | ||
- `bye` - Exit program | ||
|
||
## Usage | ||
|
||
### todo {Task} - Add a Todo Task | ||
Example: `todo study` | ||
Expected outcome: | ||
``` | ||
Got it. I've added this task: | ||
[T][ ] study | ||
``` | ||
|
||
### deadline {Task} /by {Date/Time} - Add a Deadline Task | ||
Example: `deadline return book /by Sun` | ||
Expected outcome: | ||
``` | ||
Got it. I've added this task: | ||
[D][ ] return book (by Sun) | ||
``` | ||
|
||
### event {Task} /from {Date/Time} /to {Date/Time} - Add a Event Task | ||
Example: `event party /from Fri 6pm /to 8pm` | ||
Expected outcome: | ||
``` | ||
Got it. I've added this task: | ||
[E][ ] party (from Fri 6pm to 8pm) | ||
``` | ||
|
||
### mark {Task Index} - Mark Task as Done | ||
Example: `mark 1` | ||
Expected outcome: | ||
``` | ||
Nice! I've marked this task as done: | ||
[T][X] study | ||
``` | ||
|
||
### unmark {Task Index} - Mark Task as Not Done | ||
Example: `unmark 2` | ||
Expected outcome: | ||
``` | ||
OK, I've marked this task as not done yet: | ||
[D][ ] return book (by Sun) | ||
``` | ||
|
||
### list - List All Tasks | ||
Example: `list` | ||
Expected outcome: | ||
``` | ||
1. [T][ ] study | ||
2. [D][ ] return book (by Sun) | ||
3. [E][ ] party (from Fri 6pm to 8pm) | ||
``` | ||
|
||
### find {Keyword} - Find Task(s) Containing Certain Keyword | ||
Example: `find book` | ||
Expected outcome: | ||
``` | ||
Here are the matching tasks in your list: | ||
1. [T][ ] read book | ||
2. [D][ ] return book (by Sun) | ||
``` | ||
|
||
### delete {Task Index} - Delete Task | ||
Example: `delete 4` | ||
Expected outcome: | ||
``` | ||
Noted. I've removed this task: | ||
[T][ ] read book | ||
``` | ||
|
||
### bye - Leave Program | ||
Example: `bye` | ||
Expected outcome: | ||
``` | ||
Bye. Hope to see you again soon. | ||
``` | ||
|
This file contains 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,94 @@ | ||
# User Guide | ||
# Duke - User Guide | ||
|
||
## Features | ||
Duke is a personal task manager designed to help you stay organized and on top of your to-do list. With its automated features, Duke streamlines task management and can significantly improve your productivity. | ||
|
||
### Feature-ABC | ||
## Features | ||
|
||
Description of the feature. | ||
### 3 Types of Tasks | ||
- `todo` - Adds a simple todo task | ||
- `deadline` - Adds a deadline task with a due date | ||
- `event` - Adds an event task with a start time and an end time | ||
|
||
### Feature-XYZ | ||
|
||
Description of the feature. | ||
### Other Functions | ||
- `mark` - Mark task as done | ||
- `unmark` - Mark task as not done | ||
- `list` - List all tasks | ||
- `find` - Find task(s) containing certain substring | ||
- `delete` - Delete a task | ||
- `bye` - Exit program | ||
|
||
## Usage | ||
|
||
### `Keyword` - Describe action | ||
|
||
Describe the action and its outcome. | ||
|
||
Example of usage: | ||
|
||
`keyword (optional arguments)` | ||
|
||
### todo {Task} - Add a Todo Task | ||
Example: `todo study` | ||
Expected outcome: | ||
``` | ||
Got it. I've added this task: | ||
[T][ ] study | ||
``` | ||
|
||
### deadline {Task} /by {Date/Time} - Add a Deadline Task | ||
Example: `deadline return book /by Sun` | ||
Expected outcome: | ||
``` | ||
Got it. I've added this task: | ||
[D][ ] return book (by Sun) | ||
``` | ||
|
||
Description of the outcome. | ||
|
||
``` | ||
expected output | ||
``` | ||
### event {Task} /from {Date/Time} /to {Date/Time} - Add a Event Task | ||
Example: `event party /from Fri 6pm /to 8pm` | ||
Expected outcome: | ||
``` | ||
Got it. I've added this task: | ||
[E][ ] party (from Fri 6pm to 8pm) | ||
``` | ||
|
||
### mark {Task Index} - Mark Task as Done | ||
Example: `mark 1` | ||
Expected outcome: | ||
``` | ||
Nice! I've marked this task as done: | ||
[T][X] study | ||
``` | ||
|
||
### unmark {Task Index} - Mark Task as Not Done | ||
Example: `unmark 2` | ||
Expected outcome: | ||
``` | ||
OK, I've marked this task as not done yet: | ||
[D][ ] return book (by Sun) | ||
``` | ||
|
||
### list - List All Tasks | ||
Example: `list` | ||
Expected outcome: | ||
``` | ||
1. [T][ ] study | ||
2. [D][ ] return book (by Sun) | ||
3. [E][ ] party (from Fri 6pm to 8pm) | ||
``` | ||
|
||
### find {Keyword} - Find Task(s) Containing Certain Keyword | ||
Example: `find book` | ||
Expected outcome: | ||
``` | ||
Here are the matching tasks in your list: | ||
1. [T][ ] read book | ||
2. [D][ ] return book (by Sun) | ||
``` | ||
|
||
### delete {Task Index} - Delete Task | ||
Example: `delete 4` | ||
Expected outcome: | ||
``` | ||
Noted. I've removed this task: | ||
[T][ ] read book | ||
``` | ||
|
||
### bye - Leave Program | ||
Example: `bye` | ||
Expected outcome: | ||
``` | ||
Bye. Hope to see you again soon. | ||
``` | ||
|
Binary file not shown.
This file contains 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,124 @@ | ||
import java.io.IOException; | ||
import java.util.Scanner; | ||
|
||
import Exception.DukeException; | ||
import Parser.Parser; | ||
import Storage.DukeStorage; | ||
import Task.Deadline; | ||
import Task.Event; | ||
import Task.Task; | ||
import Task.TaskList; | ||
import Task.Todo; | ||
import 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); | ||
/** | ||
* Constructor to initiate the program | ||
* | ||
* @param filePath the path to the file | ||
* @throws DukeException | ||
* @throws IOException | ||
* | ||
*/ | ||
public Duke(String filePath) throws DukeException, IOException { | ||
Ui.greet(); | ||
DukeStorage storage = new DukeStorage(filePath); | ||
Task.numberOfTasks = 0; | ||
TaskList taskList = new TaskList(storage); | ||
try (Scanner scan = new Scanner(System.in)) { | ||
String input = scan.nextLine(); | ||
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. "Arrow Head" code, maybe you can consider avoiding deep nesting? |
||
while (!input.equals("bye")) { | ||
try { | ||
if (input.equals("list")) { | ||
Ui.printList(taskList.getTasks()); | ||
|
||
} else if (input.startsWith("mark")) { | ||
String[] marks = Parser.processInput(input); | ||
int index = Parser.checkActionInputValidity(marks); | ||
if (index == -1) { | ||
throw new Exception(); | ||
} | ||
taskList.getTasks().get(index).markAsDone(); | ||
Ui.markMessage(taskList.getTasks(), index); | ||
} else if (input.startsWith("unmark")) { | ||
String[] marks = Parser.processInput(input); | ||
int index = Parser.checkActionInputValidity(marks); | ||
if (index == -1) { | ||
throw new Exception(); | ||
} | ||
taskList.getTasks().get(index).markAsNotDone(); | ||
Ui.unmarkMessage(taskList.getTasks(), index); | ||
} else if (input.startsWith("find")) { | ||
String findString = Parser.processFindString(input); | ||
if (findString == "") { | ||
throw new Exception(); | ||
} | ||
Ui.findTask(taskList.getTasks(), findString); | ||
} else if (input.startsWith("todo", 0)) { | ||
String toDoDesc = Parser.processTodoString(input); | ||
if (toDoDesc == "") { | ||
throw new Exception(); | ||
} | ||
Task toDo = new Todo(toDoDesc); | ||
taskList.addTask(toDo); | ||
Ui.printConfirmation(toDo, "TODO"); | ||
} else if (input.startsWith("deadline", 0)) { | ||
String[] deadlineArray = Parser.processDeadlineString(input); | ||
if (deadlineArray.length == 0) { | ||
throw new Exception(); | ||
} | ||
String deadlineDesc = deadlineArray[0]; | ||
String deadlineDay = deadlineArray[1]; | ||
Task deadline = new Deadline(deadlineDesc, deadlineDay); | ||
taskList.addTask(deadline); | ||
Ui.printConfirmation(deadline, "DEADLINE"); | ||
} else if (input.startsWith("event", 0)) { | ||
String[] eventArray = Parser.processEventString(input); | ||
if (eventArray.length == 0) { | ||
throw new Exception(); | ||
} | ||
String eventDesc = eventArray[0]; | ||
String start = eventArray[1]; | ||
String end = eventArray[2]; | ||
Task event = new Event(eventDesc, start, end); | ||
taskList.addTask(event); | ||
Ui.printConfirmation(event, "EVENT"); | ||
} else if (input.startsWith("delete")) { | ||
String[] deleteStrings = Parser.processInput(input); | ||
int toDelete = Parser.checkActionInputValidity(deleteStrings); | ||
if (toDelete == -1) { | ||
throw new Exception(); | ||
} | ||
Task deleteTask = taskList.getTasks().get(toDelete); | ||
taskList.removeTask(deleteTask); | ||
Task.decrementNumberOfTasks(); | ||
Ui.printConfirmation(deleteTask, "DELETE"); | ||
} else { | ||
Ui.printConfirmation(null, "UNRECOGNIZED"); | ||
; | ||
} | ||
} catch (Exception e) { | ||
Ui.printIncompleteMessage(); | ||
} | ||
|
||
input = scan.nextLine(); | ||
} | ||
} catch (NumberFormatException e) { | ||
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. Good use of exceptions here |
||
e.printStackTrace(); | ||
} | ||
Ui.bye(); | ||
storage.saveTaskList(taskList.getTasks()); | ||
} | ||
|
||
/** | ||
* main function | ||
* | ||
* @throws DukeException | ||
* @throws IOException | ||
* | ||
*/ | ||
public static void main(String[] args) throws DukeException, IOException { | ||
new Duke("data/duke.txt"); | ||
} | ||
|
||
} |
This file contains 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,12 @@ | ||
package Exception; | ||
|
||
public class DukeException extends Exception { | ||
/** | ||
* This method throws an exception. | ||
* | ||
* @param message the exception message | ||
*/ | ||
public DukeException(String message) { | ||
super(message); | ||
} | ||
} |
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.
Please follow the Java coding standards when using exceptions.