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

[Vanessa] iP #314

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d839859
Add Gradle support
May 24, 2020
253e8b0
level1-gary
Jan 23, 2022
3427794
level2-gary
Jan 23, 2022
e6d31a7
level3-gary
Jan 24, 2022
9dbe82d
Level4-gary
Jan 24, 2022
be1a567
Level5-gary
Jan 24, 2022
3ec0b1a
Level6-Gary
Jan 24, 2022
0f521e8
add memory feature in branch-Level-7
vanessaxuuan Feb 2, 2022
8f52035
add dates and times
vanessaxuuan Feb 7, 2022
8e8980b
Merge branch 'branch-Level-8'
vanessaxuuan Feb 7, 2022
2c96f56
use more OOP by extracting classes
vanessaxuuan Feb 9, 2022
733ba9a
divide classes into packages
vanessaxuuan Feb 9, 2022
4aa2a9e
add JUnit tests
vanessaxuuan Feb 9, 2022
54cd499
add JavaDoc comments
vanessaxuuan Feb 10, 2022
57426c5
Add JavaDoc comments to test classes
vanessaxuuan Feb 10, 2022
95693f5
Add JavaDoc comments
vanessaxuuan Feb 10, 2022
76d36c7
Follow the Coding Standard
vanessaxuuan Feb 10, 2022
8d822c0
Add a method to find a task by searching for a keyword
vanessaxuuan Feb 10, 2022
a30df56
rebase
vanessaxuuan Feb 10, 2022
2fa50d7
Update IP description
vanessaxuuan Feb 13, 2022
d48749e
Merge branch 'master' of https://github.com/vanessaxuuan/ip
vanessaxuuan Feb 13, 2022
9095cf4
Merge commit 'd8398594b7bc43da5eb865321c5a50cec4b3923d'
vanessaxuuan Feb 16, 2022
06be999
Set up gradle
vanessaxuuan Feb 16, 2022
35b7840
Add GUI to Gary
vanessaxuuan Feb 19, 2022
8315ecb
Add GUI to Gary
vanessaxuuan Feb 19, 2022
3aea752
Add FXML files
vanessaxuuan Feb 19, 2022
714e529
Integrate FXML into GUI for Gary
vanessaxuuan Feb 19, 2022
0bccd26
Add assert features to document important assumptions
vanessaxuuan Feb 20, 2022
3199aad
Rename packages
vanessaxuuan Feb 20, 2022
71183f3
Improve code quality
vanessaxuuan Feb 20, 2022
3d78dc3
Merge pull request #3 from vanessaxuuan/branch-A-CodeQuality
vanessaxuuan Feb 20, 2022
b76a2d5
Merge branch 'master' of https://github.com/vanessaxuuan/ip
vanessaxuuan Feb 20, 2022
6389773
Resolve merge conflicts with master branch
vanessaxuuan Feb 20, 2022
f260392
Merge pull request #2 from vanessaxuuan/branch-A-Assertions
vanessaxuuan Feb 20, 2022
5bd4d38
Merge branch 'master' of https://github.com/vanessaxuuan/ip
vanessaxuuan Feb 20, 2022
bbdb6ff
Update JavaDocs
vanessaxuuan Feb 20, 2022
fd09a66
Finalize GUI
vanessaxuuan Feb 20, 2022
9587526
Merge branch 'branch-better-GUI'
vanessaxuuan Feb 20, 2022
99e35f2
Add a representative screenshot of Gary
vanessaxuuan Feb 20, 2022
ccee2a0
Add User Guide
vanessaxuuan Feb 20, 2022
b7b8d31
Update README.md
vanessaxuuan Feb 20, 2022
fea6ca1
Update User Guide
vanessaxuuan Feb 20, 2022
7d58559
Update README.md
vanessaxuuan Feb 20, 2022
196330e
Update README.md
vanessaxuuan Feb 20, 2022
6637131
Update README.md
vanessaxuuan Feb 20, 2022
02f6bbd
Update README.md
vanessaxuuan Feb 20, 2022
fa0b705
Update README.md
vanessaxuuan Feb 20, 2022
de0f6b7
Merge branch 'master' of https://github.com/vanessaxuuan/ip
vanessaxuuan Feb 20, 2022
4e6a065
Create Jar file
vanessaxuuan Feb 21, 2022
e07b092
update jar file
vanessaxuuan Apr 14, 2022
4d9ff92
update README.md
vanessaxuuan Apr 15, 2022
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
13 changes: 13 additions & 0 deletions src/main/java/Deadlines.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Deadlines extends Task {
String date;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have an access modifier for these fields. Same comment for Event.


public Deadlines(String str, String date) {
super(str);
this.date = date;
}

@Override
public String toString() {
return "D" + super.toString() + " by: " + date;
}
}
13 changes: 13 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class Event extends Task {
String date;

public Event(String str, String date) {
super(str);
this.date = date;
}

@Override
public String toString() {
return "E" + super.toString() + " on: " + date;
}
}
98 changes: 98 additions & 0 deletions src/main/java/Gary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import java.sql.Array;
import java.util.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't imported classes be listed explicitly?


public class Gary {
public static void main(String[] args) throws GaryException {

System.out.println("Hello, i'm Gary! What's on your to do list today?\n");
Scanner sc = new Scanner(System.in);
ArrayList<Task> items = new ArrayList<>();

String nxt = sc.nextLine();

while (!nxt.equals("bye")) {

if (nxt.equals("list")) {
Gary.printList(1, items);
} else if (nxt.equals("mark")) {
System.out.println("which tasks have you completed? e.g. 2 3");
String nums = sc.nextLine();
String[] first = nums.split(" ");
int i = 0;
for (String str : first) {
items.get(Integer.parseInt(first[i]) - 1).toMark();
i++;
}
Gary.printList(2, items);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you enabled multi-step commands!


} else if (nxt.equals("unmark")) {
System.out.println("made some mistakes?");
String nums = sc.nextLine();
String[] first = nums.split(" ");
int k = 0;
for (String str : first) {
items.get(Integer.parseInt(first[k]) - 1).toUnmark();
k++;
}
} else if (nxt.equals("delete")) {
System.out.println("Please key in what you would like to remove in descending order!");
try {
String nums = sc.nextLine();
String[] first = nums.split(" ");
int k = 0;
for (String str : first) {
items.remove(Integer.parseInt(first[k]) - 1);
k++;
}
Gary.printList(2, items);
} catch (IndexOutOfBoundsException e) {
System.out.println("Ah please enter a valid number or sequence e.g. 5 3 1");
}

} else {
String[] type = nxt.split(" ");
String theTask = type[0];
try {
if (!theTask.equals("todo") && !theTask.equals("event") && !theTask.equals("deadline")) {
throw new GaryException(nxt); // invalid input
}
} catch (GaryException e) {
e.GaryError();
}

try {
switch (theTask) {
case "todo":
items.add(new ToDo(nxt.substring(5)));
break;
case "event":
String[] e = nxt.split("/", 5);
items.add(new Event(e[0].substring(6), e[1]));
break;
case "deadline":
String[] d = nxt.split("/", 5);
items.add(new Deadlines(d[0].substring(9), d[1]));
break;
}
} catch (StringIndexOutOfBoundsException e) {
System.out.println("Ah please enter a valid description e.g. task_type name / date");
}
}
nxt = sc.nextLine(); // continue getting inputs
}
System.out.println("Bye, hope you stay productive!\n");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parser is clean and easy to understand!

}

public static void printList(int type, ArrayList<Task> item) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the variable name should be in plural form for ArrayList?

if (type == 1) {
System.out.println("Tasks:");
} else {
System.out.println("Alright, this is your updated to do list");
}
int j = 1;
for (Task str : item) {
System.out.printf("%d. %s\n", j, str);
j++;
}
}
}
14 changes: 14 additions & 0 deletions src/main/java/GaryException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public class GaryException extends Exception {
// represent exceptions specific to Gary
// int err;
String msg;

public GaryException(String msg) {
// this.err = err;
this.msg = msg;
}

public void GaryError() {
System.out.printf("Sorry, what is %s ?\n", this.msg);
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be useful to add javadocs documentation for custom exceptions!

25 changes: 25 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't imported classes be listed explicitly?


public class Task {
protected String task;
protected boolean isDone;

public Task(String task) {
this.task = task;
this.isDone = false;
}

public void toMark() {
this.isDone = true;
}

public void toUnmark() {
this.isDone = false;
}

@Override
public String toString() {
String done = this.isDone ? "X" : " ";
return "[" + done + "] " + this.task;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toString is abstracted well for Task and its children classes!

}
11 changes: 11 additions & 0 deletions src/main/java/ToDo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class ToDo extends Task {

public ToDo(String str) {
super(str);
}

@Override
public String toString() {
return "T" + super.toString();
}
}
13 changes: 7 additions & 6 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
Hello, i'm Gary! What's on your to do list today?
which tasks have you completed? e.g. 2 3
Alright, this is your updated to do list
1. T[X] watch Red Notice
Bye, hope you stay productive!



4 changes: 4 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
todo watch Red Notice
mark
1
bye
2 changes: 1 addition & 1 deletion text-ui-test/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ then
fi

# run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
java -classpath ../bin Duke < input.txt > ACTUAL.TXT
java -classpath ../bin Gary < input.txt > ACTUAL.TXT

# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT
Expand Down