-
Notifications
You must be signed in to change notification settings - Fork 267
[Han Jiyao] iP #303
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
HanJiyao
wants to merge
63
commits into
nus-cs2103-AY2122S2:master
Choose a base branch
from
HanJiyao: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
[Han Jiyao] iP #303
Changes from 8 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
d839859
Add Gradle support
1c58c46
Greet, Echo, Exit
HanJiyao c9eb14c
Add, List
HanJiyao 155a643
Mark as Done
HanJiyao 4957053
ToDos, Events, Deadlines
HanJiyao f2253e1
Automated Text UI Testing
HanJiyao 3838a18
Handle Errors
HanJiyao b597f58
Delete
HanJiyao 487f743
Use Enums
HanJiyao 56225e7
Configure workflow
HanJiyao 48e2f6d
Save
HanJiyao 4d1eb80
Dates and Times
HanJiyao 7091195
Merge Dates and Times
HanJiyao 8b9cda8
Mark correction
HanJiyao 2e9dc51
Use More OOP
HanJiyao 1c8552d
Organize into Packages
HanJiyao f5a3b70
Merge remote-tracking branch 'origin/add-gradle-support'
HanJiyao eff6e71
Create New Gradle and put in source
HanJiyao 6d47139
Merge branch 'branch-A-Gradle'
HanJiyao c56753c
Add JUnit Tests
HanJiyao 08c07f8
Create a JAR File
HanJiyao dce93d4
Find
HanJiyao 81fc655
Add JavaDoc comments
HanJiyao 101e5d5
Tweak the code to comply with a coding standard
HanJiyao 434b8e2
Merge branch 'branch-A-CodingStandard'
HanJiyao 4bdbade
Merge branch 'branch-Level-9'
HanJiyao d10fbdf
Use CheckStyle
HanJiyao 5049a11
update find
HanJiyao b101cee
Update find
HanJiyao 6597d68
Merge remote-tracking branch 'origin/branch-Level-9' into branch-Level-9
HanJiyao 950a50a
GUI
HanJiyao 4b1d394
GUI FXML and css
HanJiyao eb80f8f
Use Varargs
HanJiyao b267473
Duke class: remove unused textUI()
HanJiyao 47ca398
Add assertion
HanJiyao 2421531
Improve code quality
HanJiyao 563adc5
Merge pull request #1 from HanJiyao/branch-A-CodeQuality
HanJiyao a5c14ef
Merge branch 'master' into branch-A-Assertions
HanJiyao be2f68d
Merge pull request #2 from HanJiyao/branch-A-Assertions
HanJiyao b56632e
Resolve name error by merging
HanJiyao 29c34e9
Clear up more code quality
HanJiyao 040bf3d
Change exit behavior
HanJiyao 0524042
Import checkstyle config
HanJiyao 6c19c88
Improve code quality change header comments and variable name
HanJiyao 807c50c
Use Streams
HanJiyao f358128
Set up CI
HanJiyao d737951
Set up CI
HanJiyao 77b7f78
Provide a way to attach priorities to items
HanJiyao e29df41
Sort items managed by app
HanJiyao dd5f585
Modify runtest
HanJiyao 34d91f6
Modify ui-test
HanJiyao e3dbb49
Merge pull request #4 from HanJiyao/branch-C-PrioritySort
HanJiyao ed249d5
Merge pull request #4 from HanJiyao/branch-C-PrioritySort
HanJiyao dbfdf37
Merge remote-tracking branch 'origin/master'
HanJiyao 2126abb
Trail commitO
HanJiyao 6cf8715
Clear up format
HanJiyao c55e9a3
Create gradle.yml
HanJiyao c2b7e71
Edit runtest
HanJiyao dff2e82
Merge remote-tracking branch 'origin/master'
HanJiyao 11f3ceb
Remove text-ui-test as no longer needed
HanJiyao deba367
Better GUI
HanJiyao dc4be77
Add a User Guide
HanJiyao 48c91bf
Bug fix date parser
HanJiyao 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| public class Deadline extends Task{ | ||
| protected String by; | ||
| public Deadline(String task, String by) { | ||
| super(task.trim()); | ||
| this.by = by.trim(); | ||
| } | ||
|
|
||
| public Deadline(String task, boolean done) { | ||
| super(task, done); | ||
| } | ||
|
|
||
| @Override | ||
| public Deadline mark() { | ||
| return new Deadline(task, true); | ||
| } | ||
|
|
||
| @Override | ||
| public Deadline unmark() { | ||
| return new Deadline(task, false); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "["+Type.D+"]" + super.toString() + " (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 |
|---|---|---|
| @@ -1,10 +1,146 @@ | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Scanner; | ||
|
|
||
| public class Duke { | ||
| public static void main(String[] args) { | ||
| String logo = " ____ _ \n" | ||
| + "| _ \\ _ _| | _____ \n" | ||
| + "| | | | | | | |/ / _ \\\n" | ||
| + "| |_| | |_| | < __/\n" | ||
| + "|____/ \\__,_|_|\\_\\___|\n"; | ||
| System.out.println("Hello from\n" + logo); | ||
| + "|____/ \\__,_|_|\\_\\___|"; | ||
| System.out.println(logo); | ||
|
|
||
| System.out.println(output("Hello! I'm Duke by A0221330A.\n What can I do for you?")); | ||
|
|
||
| ArrayList<Task> list = new ArrayList<>(); | ||
|
|
||
| boolean exit = false; | ||
| while (!exit) { | ||
| Scanner sc = new Scanner(System.in); | ||
| while (sc.hasNextLine()) { | ||
| List<String> input = Arrays.asList(sc.nextLine().split(" ")); | ||
| switch (input.get(0)) { | ||
| case "bye": | ||
| System.out.println(output("Bye. Hope to see you again soon!")); | ||
| exit = true; | ||
| break; | ||
| case "list": | ||
| StringBuilder text = new StringBuilder(); | ||
| text.append("Here are the tasks in your list:\n"); | ||
| for (int i = 0; i < list.size(); i++) { | ||
| text.append(" ").append(i + 1).append(". ") | ||
| .append(list.get(i)) | ||
| .append("\n"); | ||
| } | ||
| text.delete(text.length() - 1, text.length()); | ||
| System.out.println(output(text.toString())); | ||
| break; | ||
| case "mark": | ||
| try { | ||
| int markIndex = Integer.parseInt(input.get(1)) - 1; | ||
| list.set(markIndex, list.get(markIndex).mark()); | ||
| System.out.println(output("Nice! I've marked this task as done:\n " | ||
| + list.get(markIndex))); | ||
| } catch (IndexOutOfBoundsException | NumberFormatException ex) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! invalid index."); | ||
| System.out.println(output(exception.toString())); | ||
| } | ||
| break; | ||
| case "unmark": | ||
| try { | ||
| int unmarkIndex = Integer.parseInt(input.get(1)) - 1; | ||
| list.set(unmarkIndex, list.get(unmarkIndex).unmark()); | ||
| System.out.println(output("OK, I've marked this task as not done yet:\n " | ||
| + list.get(unmarkIndex))); | ||
| } catch (IndexOutOfBoundsException | NumberFormatException ex) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! invalid index."); | ||
| System.out.println(output(exception.toString())); | ||
| } | ||
| break; | ||
| case "todo": | ||
| StringBuilder todo = new StringBuilder(); | ||
| if (input.size() == 1) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! The description of a todo cannot be empty."); | ||
| System.out.println(output(exception.toString())); | ||
| } else { | ||
| for (int i = 1; i < input.size(); i++) { | ||
| todo.append(input.get(i)).append(" "); | ||
| } | ||
| list.add(new ToDo(todo.toString())); | ||
| System.out.println(output("Got it. I've added this task: \n " | ||
| + list.get(list.size() - 1) + "\n Now you have " + list.size() + " tasks in the list.")); | ||
| } | ||
| break; | ||
|
|
||
| case "deadline": | ||
| StringBuilder deadline = new StringBuilder(); | ||
| StringBuilder deadlineBy = new StringBuilder(); | ||
|
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. Maybe can encapsulate this functionality in another class if you want |
||
| int byIndex = input.indexOf("/by"); | ||
| if (input.size() == 1) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! The description of a deadline cannot be empty."); | ||
| System.out.println(output(exception.toString())); | ||
| } else if (byIndex == -1) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! The datetime of a deadline cannot be empty."); | ||
| System.out.println(output(exception.toString())); | ||
| } else { | ||
| for (int i = 1; i < byIndex; i++) { | ||
| deadline.append(input.get(i)).append(" "); | ||
| } | ||
| for (int i = byIndex + 1; i < input.size(); i++) { | ||
| deadlineBy.append(input.get(i)).append(" "); | ||
| } | ||
| list.add(new Deadline(deadline.toString(), deadlineBy.toString())); | ||
| System.out.println(output("Got it. I've added this task: \n " | ||
| + list.get(list.size() - 1) + "\n Now you have " + list.size() + " tasks in the list.")); | ||
| } | ||
| break; | ||
| case "event": | ||
| int atIndex = input.indexOf("/at"); | ||
| if (input.size() == 1) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! The description of a event cannot be empty."); | ||
| System.out.println(output(exception.toString())); | ||
| } else if (atIndex == -1) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! The datetime of a event cannot be empty."); | ||
| System.out.println(output(exception.toString())); | ||
| } else { | ||
| StringBuilder event = new StringBuilder(); | ||
| for (int i = 1; i < atIndex; i++) { | ||
| event.append(input.get(i)).append(" "); | ||
| } | ||
| StringBuilder eventAt = new StringBuilder(); | ||
| for (int i = atIndex + 1; i < input.size(); i++) { | ||
| eventAt.append(input.get(i)).append(" "); | ||
| } | ||
| list.add(new Event(event.toString(), eventAt.toString())); | ||
| System.out.println(output("Got it. I've added this task: \n " | ||
| + list.get(list.size() - 1) + "\n Now you have " + list.size() + " tasks in the list.")); | ||
| } | ||
| break; | ||
| case "delete": | ||
| try { | ||
| int deleteIndex = Integer.parseInt(input.get(1)) - 1; | ||
| Task delete = list.get(deleteIndex); | ||
| list.remove(deleteIndex); | ||
| System.out.println(output("Noted. I've removed this task: \n " | ||
| + delete + "\n Now you have " + list.size() + " tasks in the list.")); | ||
| } catch (IndexOutOfBoundsException | NumberFormatException ex) { | ||
| DukeException exception = new DukeException("☹ OOPS!!! invalid index."); | ||
| System.out.println(output(exception.toString())); | ||
| } | ||
| break; | ||
| default: | ||
| DukeException exception = new DukeException("☹ OOPS!!! I'm sorry, but I don't know what that means :-("); | ||
| System.out.println(output(exception.toString())); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static String output(String text) { | ||
| String line = " ____________________________________________________________"; | ||
| return line + "\n " + text + "\n" + line; | ||
| } | ||
| } | ||
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,10 @@ | ||
| public class DukeException extends Exception { | ||
| public DukeException(String errMsg) { | ||
| super(errMsg); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return super.getMessage(); | ||
| } | ||
| } |
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 @@ | ||
| public class Event extends Task{ | ||
| protected String at; | ||
| public Event(String task, String at) { | ||
| super(task.trim()); | ||
| this.at = at.trim(); | ||
| } | ||
|
|
||
| public Event(String task, boolean done) { | ||
|
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. Easy to read! |
||
| super(task, done); | ||
| } | ||
|
|
||
| @Override | ||
| public Event mark() { | ||
| return new Event(task, true); | ||
| } | ||
|
|
||
| @Override | ||
| public Event unmark() { | ||
| return new Event(task, false); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "["+Type.E+"]" + super.toString() + " (at: " + at + ")"; | ||
| } | ||
| } | ||
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 Task { | ||
| protected String task; | ||
| protected boolean done; | ||
|
|
||
| public Task(String task) { | ||
| this.task = task; | ||
| this.done = false; | ||
| } | ||
|
|
||
| public Task(String task, boolean done) { | ||
| this.task = task; | ||
| this.done = done; | ||
| } | ||
|
|
||
| public Task mark() { | ||
| return new Task(task, true); | ||
| } | ||
|
|
||
| public Task unmark() { | ||
| return new Task(task, false); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return done? "[✓] " + task: "[ ] " + task; | ||
| } | ||
| } |
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 @@ | ||
| public class ToDo extends Task{ | ||
| public ToDo(String task) { | ||
| super(task.trim()); | ||
| } | ||
|
|
||
| public ToDo(String task, boolean done) { | ||
| super(task, done); | ||
| } | ||
|
|
||
| @Override | ||
| public ToDo mark() { | ||
| return new ToDo(task, true); | ||
| } | ||
|
|
||
| @Override | ||
| public ToDo unmark() { | ||
| return new ToDo(task, false); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "["+Type.T+"]" + super.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,3 @@ | ||
| public enum Type { | ||
| T, D, E | ||
| } |
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,7 +1,63 @@ | ||
| Hello from | ||
| ____ _ | ||
| | _ \ _ _| | _____ | ||
| ____ _ | ||
| | _ \ _ _| | _____ | ||
| | | | | | | | |/ / _ \ | ||
| | |_| | |_| | < __/ | ||
| |____/ \__,_|_|\_\___| | ||
|
|
||
| ____________________________________________________________ | ||
| Hello! I'm Duke by A0221330A. | ||
| What can I do for you? | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [T][ ] read book | ||
| Now you have 1 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [D][ ] return book (by: June 6th) | ||
| Now you have 2 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [E][ ] project meeting (at: Aug 6th 2-4pm) | ||
| Now you have 3 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [T][ ] join sports club | ||
| Now you have 4 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Nice! I've marked this task as done: | ||
| [T][✓] read book | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Nice! I've marked this task as done: | ||
| [T][✓] join sports club | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [T][ ] borrow book | ||
| Now you have 5 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Here are the tasks in your list: | ||
| 1. [T][✓] read book | ||
| 2. [D][ ] return book (by: June 6th) | ||
| 3. [E][ ] project meeting (at: Aug 6th 2-4pm) | ||
| 4. [T][✓] join sports club | ||
| 5. [T][ ] borrow book | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [D][ ] return book (by: Sunday) | ||
| Now you have 6 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [E][ ] project meeting (at: Mon 2-4 pm) | ||
| Now you have 7 tasks in the list. | ||
| ____________________________________________________________ | ||
| ____________________________________________________________ | ||
| Bye. Hope to see you again soon! | ||
| ____________________________________________________________ |
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,11 @@ | ||
| todo read book | ||
| deadline return book /by June 6th | ||
| event project meeting /at Aug 6th 2-4pm | ||
| todo join sports club | ||
| mark 1 | ||
| mark 4 | ||
| todo borrow book | ||
| list | ||
| deadline return book /by Sunday | ||
| event project meeting /at Mon 2-4 pm | ||
| bye |
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.
Well done on the naming of variables, they are easily read!