-
Notifications
You must be signed in to change notification settings - Fork 361
[ryanchua00] iP #363
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
ryanchua00
wants to merge
52
commits into
nus-cs2103-AY2223S2:master
Choose a base branch
from
ryanchua00: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
[ryanchua00] iP #363
Changes from 11 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
556af3f
Add Gradle support
6be16cb
level-1:
ryanchua00 5cc2b61
Level-2
ryanchua00 7a9ce73
Level-2: Fix
ryanchua00 e485de4
Level-3
ryanchua00 fac3a48
Level-3
ryanchua00 0d39797
Level-4
ryanchua00 3afcf4b
Level-4
ryanchua00 bc36003
A-TextUiTesting
ryanchua00 cb91a1a
Level-5
ryanchua00 38a71b7
Level-5
ryanchua00 862223e
Level-6:
ryanchua00 573fa47
Level-7
ryanchua00 8bd4863
Level-8
ryanchua00 0a197fe
Merge branch 'branch-Level-7'
ryanchua00 b263cba
Merge branch 'branch-Level-8'
ryanchua00 a8f772e
A-MoreOOP v1.0
ryanchua00 557669b
A-MoreOOP v2.0
ryanchua00 1340468
A-Packages
ryanchua00 3977717
Merge branch 'add-gradle-support'
ryanchua00 285a66e
A-Gradle
ryanchua00 2be4706
A-JUnit
ryanchua00 f1a96fa
A-Jar
ryanchua00 39f5232
A-Javadoc
ryanchua00 7bbafde
A-CodingStandard
ryanchua00 904c901
Level-9
ryanchua00 85ef6db
Merge branch 'branch-A-JavaDoc'
ryanchua00 7c2e668
Merge branch 'branch-A-CodingStandard'
ryanchua00 35b2606
Merge branch 'branch-Level-9'
ryanchua00 70d1d24
Level-10 Base
ryanchua00 2ba864a
Added Graphic User Interface(GUI) functionality
ryanchua00 48f46fe
Improve Exception handling
ryanchua00 21157cf
A-Assertions
ryanchua00 87ec5cb
Add custom commands
ryanchua00 72cf26c
Merge pull request #1 from ryanchua00/branch-A-CodeQuality
ryanchua00 6ad870f
Merge branch 'master' into branch-A-Assertions
ryanchua00 746e73a
Merge pull request #3 from ryanchua00/branch-A-Assertions
ryanchua00 ede39f9
Create gradle.yml
ryanchua00 3bb378f
Update gradle.yml
ryanchua00 07f31ec
Update Storage.java
ryanchua00 8390888
Fixing according to CI
ryanchua00 ded1829
Fix for Ci
ryanchua00 1ffffbc
Add help functionality
ryanchua00 3a858a6
Merge pull request #4 from ryanchua00/branch-C-Help
ryanchua00 0da28ad
Improve Code Quality
ryanchua00 bf3d7ea
Improve GUI
ryanchua00 57debaa
Add User Guide
ryanchua00 2d5afcd
Change photo in README
ryanchua00 6fa3281
Changed UI picture file name
ryanchua00 90d31b4
Changing name pt1
ryanchua00 d7d659b
Change Ui.png
ryanchua00 070aed0
Added picture to Docs folder
ryanchua00 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,22 @@ | ||
| public class Deadline extends Task{ | ||
| private String deadline; | ||
| private char type = 'D'; | ||
| public Deadline(String description, String date){ | ||
| super(description); | ||
| this.deadline = date; | ||
| } | ||
| public void setDeadline(String date){ | ||
| this.deadline = date; | ||
| } | ||
| public String getDeadline(){ | ||
| return this.deadline; | ||
| } | ||
| @Override | ||
| public char getType() { | ||
| return type; | ||
| } | ||
| @Override | ||
| public String toString(){ | ||
| return super.toString() + "(by: "+ deadline + ")"; | ||
| } | ||
| } |
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 Event extends Task { | ||
| private String start; | ||
| private String end; | ||
| private char type = 'E'; | ||
| public Event(String description, String start, String end) { | ||
| super(description); | ||
| this.start = start; | ||
| this.end = end; | ||
| } | ||
| public void setStart(String time){ | ||
| this.start = time; | ||
| } | ||
| public void setEnd(String time){ | ||
| this.end = time; | ||
| } | ||
| public String getStart(){ | ||
| return this.start; | ||
| } | ||
| public String getEnd(){ | ||
| return this.end; | ||
| } | ||
| @Override | ||
| public char getType() { | ||
| return type; | ||
| } | ||
| @Override | ||
| public String toString(){ | ||
| return super.toString() + "(from: " + start + "to: " + end + ")"; | ||
| } | ||
| } |
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,192 @@ | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Scanner; | ||
|
|
||
| public class Roody { | ||
| private ArrayList<Task> list; | ||
| private List<String> printBuffer; | ||
|
|
||
| public Roody(){ | ||
| // Assumed no more than 100 tasks | ||
| this.list = new ArrayList<Task>(); | ||
| this.printBuffer = new ArrayList<String>(); | ||
| } | ||
|
|
||
| // Provides basic line | ||
| private void line() { | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
|
|
||
| // Repeats the input | ||
| private void speak(String input) { | ||
| line(); | ||
| System.out.println(input); | ||
| line(); | ||
| } | ||
| private void speak(List<String> inputs) { | ||
| line(); | ||
| inputs.forEach(x -> System.out.println(x)); | ||
| line(); | ||
| inputs.clear(); | ||
| } | ||
|
|
||
| // Initial Greeting | ||
| public void greet() { | ||
| this.printBuffer.add("Hello, I'm Roody!"); | ||
| this.printBuffer.add("What can I do for you?"); | ||
| speak(this.printBuffer); | ||
| } | ||
|
|
||
| // final greeting | ||
| public void bye() { | ||
| speak("Bye. Hope to see you again soon!"); | ||
| } | ||
|
|
||
| // Stores input to string | ||
| private void addToList(String input) { | ||
| String[] inputs = input.split("/"); | ||
| Task task = new Todo(input.substring("todo ".length())); | ||
| char type = input.charAt(0); | ||
| if (type == 't') { | ||
| } else if (type == 'd') { | ||
| // more than one / detected, | ||
| if (inputs.length > 2) { | ||
| new RoodyException("I don't understand that. Don't use additonal \"/\" for deadlines."); | ||
| return; | ||
| } else { | ||
| task = new Deadline(inputs[0].substring("deadline ".length()), inputs[1].substring("by ".length())); | ||
| } | ||
| } else if (type == 'e') { | ||
| // more or less than two / detected, | ||
| if (inputs.length != 3) { | ||
| new RoodyException("I don't understand that. Don't use additonal \"/\" for events."); | ||
| return; | ||
| } else { | ||
| task = new Event(inputs[0].substring("event ".length()), inputs[1].substring("from ".length()), inputs[2].substring("to ".length())); | ||
| } | ||
| } else { | ||
| new RoodyException("Error, wrong input detected"); | ||
| return; | ||
| } | ||
| list.add(task); | ||
| printBuffer.add("Got it. I've added this task:"); | ||
| printBuffer.add(" [" + task.getType() +"][ ] " + task.toString()); | ||
| printBuffer.add("Now you have " + list.size() + " tasks in the list."); | ||
| speak(printBuffer); | ||
| } | ||
|
|
||
| // Prints entire list in this.list | ||
| private void printList() { | ||
| int count = 0; | ||
| int listIndex = 0; | ||
| StringBuilder stringBuilder = new StringBuilder(); | ||
| if (!list.isEmpty()) { | ||
| printBuffer.add("Here are the tasks in your list:"); | ||
| while (count < list.size()) { | ||
|
|
||
| listIndex = count + 1; | ||
| stringBuilder.append(listIndex); | ||
| stringBuilder.append(".["); | ||
| // get type | ||
| stringBuilder.append(list.get(count).getType()); | ||
| stringBuilder.append("]["); | ||
| // if is done, set as 'X' | ||
| if (list.get(count).isDone()) { | ||
| stringBuilder.append("X] "); | ||
| // not done, set as ' ' | ||
| } else { | ||
| stringBuilder.append(" ] "); | ||
| } | ||
| stringBuilder.append(list.get(count).toString()); | ||
| printBuffer.add(stringBuilder.toString()); | ||
|
|
||
| // Clears and updates values | ||
| stringBuilder.setLength(0); | ||
| count++; | ||
| } | ||
| speak(printBuffer); | ||
| } else { | ||
| new RoodyException("There doesn't seem to be any tasks in your list."); | ||
| } | ||
| } | ||
|
|
||
| // toggles completion status of tasks | ||
| private void complete(String index, boolean complete){ | ||
| int taskIndex = Integer.parseInt(index) - 1; | ||
| if (taskIndex > list.size() - 1 || list.get(taskIndex) == null) { | ||
| new RoodyException("Sorry, that task doesn't exist"); | ||
| } else { | ||
| Task task = list.get(taskIndex); | ||
| if (complete) { | ||
| task.setDone(); | ||
| printBuffer.add("Nice! I've marked this task as done:"); | ||
| printBuffer.add("["+ task.getType()+"][X] " + task.toString()); | ||
| } else { | ||
| task.setUnDone(); | ||
| printBuffer.add("OK, I've marked this task as not done yet:"); | ||
| printBuffer.add("["+ task.getType()+"][ ] " + task.toString()); | ||
| } | ||
| speak(printBuffer); | ||
| } | ||
| } | ||
|
|
||
| private void delete(String index) { | ||
| int taskIndex = Integer.parseInt(index) - 1; | ||
| if (taskIndex > list.size() - 1 || list.get(taskIndex) == null) { | ||
| new RoodyException("Sorry, that task doesn't exist"); | ||
| } else { | ||
| Task task = list.get(taskIndex); | ||
| printBuffer.add("Noted. I've removed this task:"); | ||
| printBuffer.add(" [" + task.getType() + "][ ] " + task.toString()); | ||
| printBuffer.add("Now you have " + (list.size()-1) + " tasks in the list."); | ||
| speak(printBuffer); | ||
| list.remove(Integer.parseInt(index) - 1); | ||
| } | ||
| } | ||
|
|
||
| public static void main(String[] args){ | ||
| Roody roody = new Roody(); | ||
| // Sends initial greeting | ||
| roody.greet(); | ||
| String input = ""; | ||
| String[] inputs; | ||
| Scanner scanner = new Scanner(System.in); | ||
| // Loops until "bye" is input | ||
| while (true) { | ||
| System.out.print("=> "); | ||
| // Read input | ||
| input = scanner.nextLine(); | ||
| inputs = input.toLowerCase().split("\\s", 0); | ||
| // If bye, break and print end message | ||
| if (inputs[0].equals("bye")) { | ||
| break; | ||
| // else, repeat | ||
| } else if (inputs[0].equals("list")) { | ||
| roody.printList(); | ||
| } else if (inputs[0].equals("delete")) { | ||
| if (inputs.length == 2) { | ||
| roody.delete(inputs[1]); | ||
| } else { | ||
| new RoodyException("Please enter a index number to be deleted"); | ||
ryanchua00 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| // Checks for second input | ||
| } else if (inputs[0].equals("mark") || inputs[0].equals("unmark")) { | ||
| if (inputs.length == 2) { | ||
| roody.complete(inputs[1], inputs[0].equals("mark")); | ||
| } else { | ||
| new RoodyException("Please enter a index number to be marked/unmarked"); | ||
| } | ||
| } else if (inputs[0].equals("todo") || inputs[0].equals("deadline") || inputs[0].equals("event")) { | ||
| if (inputs.length > 1) { | ||
| roody.addToList(input); | ||
| } else { | ||
| new RoodyException("Tasks require a description"); | ||
| } | ||
| } else { | ||
| new RoodyException("I don't quite understand that."); | ||
| } | ||
| } | ||
| scanner.close(); | ||
| roody.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,13 @@ | ||
| public class RoodyException{ | ||
| private String message = "Oh no :( "; | ||
| public RoodyException(String s) { | ||
| this.message += s; | ||
| line(); | ||
| System.out.println(this.message); | ||
| line(); | ||
| } | ||
| // Provides basic line | ||
| private void line() { | ||
| System.out.println("____________________________________________________________"); | ||
| } | ||
| } |
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 abstract class Task { | ||
| private boolean done; | ||
| private String description; | ||
| public Task(String description) { | ||
| this.done = false; | ||
| this.description = description; | ||
| } | ||
| public boolean isDone() { | ||
| return this.done; | ||
| } | ||
| public void setDone() { | ||
| this.done = true; | ||
| } | ||
| public void setUnDone() { | ||
| this.done = false; | ||
| } | ||
| public char getType() { | ||
| return 'a'; | ||
| } | ||
| @Override | ||
| public String toString(){ | ||
| return this.description; | ||
| } | ||
| } |
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,14 @@ | ||
| public class Todo extends Task { | ||
| private char type = 'T'; | ||
| public Todo(String description){ | ||
| super(description); | ||
| } | ||
| @Override | ||
| public char getType() { | ||
| return type; | ||
| } | ||
| @Override | ||
| public String toString(){ | ||
| return 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 |
|---|---|---|
| @@ -1,7 +1,65 @@ | ||
| Hello from | ||
| ____ _ | ||
| | _ \ _ _| | _____ | ||
| | | | | | | | |/ / _ \ | ||
| | |_| | |_| | < __/ | ||
| |____/ \__,_|_|\_\___| | ||
|
|
||
| ____________________________________________________________ | ||
| Hello, I'm Roody! | ||
| What can I do for you? | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [T][ ] JS2230 readings | ||
| Now you have 1 tasks in the list. | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [E][ ] Japan Trip (from: January 25th to: February 2nd) | ||
| Now you have 2 tasks in the list. | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [D][ ] Japan Admin (Mum) (by: Thursday) | ||
| Now you have 3 tasks in the list. | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Here are the tasks in your list: | ||
| 1.[T][ ] JS2230 readings | ||
| 2.[E][ ] Japan Trip (from: January 25th to: February 2nd) | ||
| 3.[D][ ] Japan Admin (Mum) (by: Thursday) | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Nice! I've marked this task as done: | ||
| [E][X] Japan Trip (from: January 25th to: February 2nd) | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| OK, I've marked this task as not done yet: | ||
| [D][ ] Japan Admin (Mum) (by: Thursday) | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Oh no :( Sorry, that task doesn't exist | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Got it. I've added this task: | ||
| [T][ ] Lunch | ||
| Now you have 4 tasks in the list. | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Here are the tasks in your list: | ||
| 1.[T][ ] JS2230 readings | ||
| 2.[E][X] Japan Trip (from: January 25th to: February 2nd) | ||
| 3.[D][ ] Japan Admin (Mum) (by: Thursday) | ||
| 4.[T][ ] Lunch | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Noted. I've removed this task: | ||
| [E][ ] Japan Trip (from: January 25th to: February 2nd) | ||
| Now you have 3 tasks in the list. | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Oh no :( Sorry, that task doesn't exist | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| Here are the tasks in your list: | ||
| 1.[T][ ] JS2230 readings | ||
| 2.[D][ ] Japan Admin (Mum) (by: Thursday) | ||
| 3.[T][ ] Lunch | ||
| ____________________________________________________________ | ||
| => ____________________________________________________________ | ||
| 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,13 @@ | ||
| todo JS2230 readings | ||
| event Japan Trip /from January 25th /to February 2nd | ||
| deadline Japan Admin (Mum) /by Thursday | ||
| list | ||
| mark 2 | ||
| unmark 3 | ||
| mark 4 | ||
| todo Lunch | ||
| list | ||
| delete 2 | ||
| delete 4 | ||
| list | ||
| 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
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.
Uh oh!
There was an error while loading. Please reload this page.