Skip to content
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

[ryanchua00] iP #363

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
6be16cb
level-1:
ryanchua00 Jan 13, 2023
5cc2b61
Level-2
ryanchua00 Jan 16, 2023
7a9ce73
Level-2: Fix
ryanchua00 Jan 16, 2023
e485de4
Level-3
ryanchua00 Jan 17, 2023
fac3a48
Level-3
ryanchua00 Jan 17, 2023
0d39797
Level-4
ryanchua00 Jan 17, 2023
3afcf4b
Level-4
ryanchua00 Jan 18, 2023
bc36003
A-TextUiTesting
ryanchua00 Jan 18, 2023
cb91a1a
Level-5
ryanchua00 Jan 18, 2023
38a71b7
Level-5
ryanchua00 Jan 18, 2023
862223e
Level-6:
ryanchua00 Jan 18, 2023
573fa47
Level-7
ryanchua00 Feb 2, 2023
8bd4863
Level-8
ryanchua00 Feb 2, 2023
0a197fe
Merge branch 'branch-Level-7'
ryanchua00 Feb 3, 2023
b263cba
Merge branch 'branch-Level-8'
ryanchua00 Feb 3, 2023
a8f772e
A-MoreOOP v1.0
ryanchua00 Feb 3, 2023
557669b
A-MoreOOP v2.0
ryanchua00 Feb 4, 2023
1340468
A-Packages
ryanchua00 Feb 4, 2023
3977717
Merge branch 'add-gradle-support'
ryanchua00 Feb 4, 2023
285a66e
A-Gradle
ryanchua00 Feb 4, 2023
2be4706
A-JUnit
ryanchua00 Feb 4, 2023
f1a96fa
A-Jar
ryanchua00 Feb 4, 2023
39f5232
A-Javadoc
ryanchua00 Feb 4, 2023
7bbafde
A-CodingStandard
ryanchua00 Feb 4, 2023
904c901
Level-9
ryanchua00 Feb 5, 2023
85ef6db
Merge branch 'branch-A-JavaDoc'
ryanchua00 Feb 5, 2023
7c2e668
Merge branch 'branch-A-CodingStandard'
ryanchua00 Feb 5, 2023
35b2606
Merge branch 'branch-Level-9'
ryanchua00 Feb 5, 2023
70d1d24
Level-10 Base
ryanchua00 Feb 6, 2023
2ba864a
Added Graphic User Interface(GUI) functionality
ryanchua00 Feb 8, 2023
48f46fe
Improve Exception handling
ryanchua00 Feb 8, 2023
21157cf
A-Assertions
ryanchua00 Feb 8, 2023
87ec5cb
Add custom commands
ryanchua00 Feb 9, 2023
72cf26c
Merge pull request #1 from ryanchua00/branch-A-CodeQuality
ryanchua00 Feb 9, 2023
6ad870f
Merge branch 'master' into branch-A-Assertions
ryanchua00 Feb 9, 2023
746e73a
Merge pull request #3 from ryanchua00/branch-A-Assertions
ryanchua00 Feb 9, 2023
ede39f9
Create gradle.yml
ryanchua00 Feb 9, 2023
3bb378f
Update gradle.yml
ryanchua00 Feb 9, 2023
07f31ec
Update Storage.java
ryanchua00 Feb 9, 2023
8390888
Fixing according to CI
ryanchua00 Feb 9, 2023
ded1829
Fix for Ci
ryanchua00 Feb 9, 2023
1ffffbc
Add help functionality
ryanchua00 Feb 9, 2023
3a858a6
Merge pull request #4 from ryanchua00/branch-C-Help
ryanchua00 Feb 10, 2023
0da28ad
Improve Code Quality
ryanchua00 Feb 15, 2023
bf3d7ea
Improve GUI
ryanchua00 Feb 15, 2023
57debaa
Add User Guide
ryanchua00 Feb 15, 2023
2d5afcd
Change photo in README
ryanchua00 Feb 15, 2023
6fa3281
Changed UI picture file name
ryanchua00 Feb 16, 2023
90d31b4
Changing name pt1
ryanchua00 Feb 16, 2023
d7d659b
Change Ui.png
ryanchua00 Feb 16, 2023
070aed0
Added picture to Docs folder
ryanchua00 Mar 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 43 additions & 20 deletions src/main/java/Roody.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import java.util.Scanner;
ryanchua00 marked this conversation as resolved.
Show resolved Hide resolved

public class Roody {
private Task[] list;
private int index;
private ArrayList<Task> list;
private List<String> printBuffer;

public Roody(){
// Assumed no more than 100 tasks
this.list = new Task[100];
this.list = new ArrayList<Task>();
this.printBuffer = new ArrayList<String>();
this.index = 0;
}

// Provides basic line
Expand Down Expand Up @@ -70,11 +68,10 @@ private void addToList(String input) {
new RoodyException("Error, wrong input detected");
return;
}
list[index] = task;
index++;
list.add(task);
printBuffer.add("Got it. I've added this task:");
printBuffer.add(" [" + task.getType() +"][ ] " + task.toString());
printBuffer.add("Now you have " + index + " tasks in the list.");
printBuffer.add("Now you have " + list.size() + " tasks in the list.");
speak(printBuffer);
}

Expand All @@ -83,24 +80,24 @@ private void printList() {
int count = 0;
int listIndex = 0;
StringBuilder stringBuilder = new StringBuilder();
if (index > 0) {
if (!list.isEmpty()) {
printBuffer.add("Here are the tasks in your list:");
while (count < this.index) {
while (count < list.size()) {

listIndex = count + 1;
stringBuilder.append(listIndex);
stringBuilder.append(".[");
// get type
stringBuilder.append(list[count].getType());
stringBuilder.append(list.get(count).getType());
stringBuilder.append("][");
// if is done, set as 'X'
if (this.list[count].isDone()) {
if (list.get(count).isDone()) {
stringBuilder.append("X] ");
// not done, set as ' '
} else {
stringBuilder.append(" ] ");
}
stringBuilder.append(list[count].toString());
stringBuilder.append(list.get(count).toString());
printBuffer.add(stringBuilder.toString());

// Clears and updates values
Expand All @@ -116,10 +113,10 @@ private void printList() {
// toggles completion status of tasks
private void complete(String index, boolean complete){
int taskIndex = Integer.parseInt(index) - 1;
if (taskIndex < list.length && list[taskIndex] == null) {
if (taskIndex > list.size() - 1 || list.get(taskIndex) == null) {
new RoodyException("Sorry, that task doesn't exist");
} else {
Task task = list[taskIndex];
Task task = list.get(taskIndex);
if (complete) {
task.setDone();
printBuffer.add("Nice! I've marked this task as done:");
Expand All @@ -133,6 +130,20 @@ private void complete(String index, boolean complete){
}
}

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
Expand All @@ -152,13 +163,25 @@ public static void main(String[] args){
// 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.
Show resolved Hide resolved
}
// Checks for second input
} else if (inputs.length > 1 && inputs[0].equals("mark")) {
roody.complete(inputs[1], true);
} else if (inputs.length > 1 && inputs[0].equals("unmark")) {
roody.complete(inputs[1], false);
} else if (inputs.length > 1 && (inputs[0].equals("todo") || inputs[0].equals("deadline") || inputs[0].equals("event"))) {
roody.addToList(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.");
}
Expand Down
16 changes: 15 additions & 1 deletion text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ OK, I've marked this task as not done yet:
[D][ ] Japan Admin (Mum) (by: Thursday)
____________________________________________________________
=> ____________________________________________________________
Sorry, this task dosen't exist
Oh no :( Sorry, that task doesn't exist
____________________________________________________________
=> ____________________________________________________________
Got it. I've added this task:
Expand All @@ -47,5 +47,19 @@ Here are the tasks in your list:
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!
____________________________________________________________
3 changes: 3 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ unmark 3
mark 4
todo Lunch
list
delete 2
delete 4
list
bye