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

[Ryan Chang Jia Jie] iP #292

Open
wants to merge 125 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
f0ac11a
add: .gitignore
Jan 20, 2022
2c93817
add: Siri/Level1.java
Jan 20, 2022
704e5b3
add javadocs comments
Jan 21, 2022
5068ebc
add Siri/Level2
Jan 21, 2022
38fcffd
update Siri/Level2
Jan 21, 2022
87d0d71
add: Level1.java
Jan 20, 2022
7b81057
add javadocs comments
Jan 21, 2022
3d16555
add Level2.java
Jan 21, 2022
2770cef
update Level2.java
Jan 21, 2022
12ba4e1
add Level3.java
Jan 21, 2022
dff1c86
neaten 1 line of code in Level2.java
Jan 21, 2022
0b68584
add Level3.java
Jan 21, 2022
a0a2092
Shift Level3.java to L3 folder
Jan 21, 2022
d152a84
add Task.java
Jan 21, 2022
a5cd7ea
update Level3.java
Jan 21, 2022
4288d48
Revert "update Level3.java"
Jan 21, 2022
f782ffb
Revert "Revert "update Level3.java""
Jan 21, 2022
37ab3af
add mark logic to Level3.java
Jan 21, 2022
ee2396d
add markAsNotDone method to Task.java
Jan 21, 2022
0d0be9c
update Level3.java
Jan 21, 2022
e45bca6
add javadoc comments to Level3.java
Jan 21, 2022
0a90fee
update Siri replies to mark and unmark user inputs
Jan 21, 2022
8ac0e8b
condense multiple system.out.println into lesser lines in Level3.java
Jan 21, 2022
05cbe45
Merge commit '38fcffd337170938ce966b3fd4cdb031fb1fb05a'
Jan 24, 2022
00f7fcf
move level1.java into L1 folder
Jan 26, 2022
432b9a4
move Level2.java into L2 folder
Jan 26, 2022
89a002f
add Level4.java into L4 folder
Jan 26, 2022
ab7e094
add Task.java to L4 folder
Jan 26, 2022
707ee94
add Todo.java to L4 folder
Jan 26, 2022
116e09e
add @Override tag in line 24 of Task.java
Jan 26, 2022
4c07809
update Todo.java
Jan 26, 2022
1fe0728
update Level4.java
Jan 26, 2022
3fc747d
add Deadline.java to L4 folder
Jan 26, 2022
1e6b55a
update Deadline.java
Jan 26, 2022
b7faffc
update Level4.java to accept deadline and todo tasks
Jan 26, 2022
bc69135
add javadoc comment to line 51
Jan 26, 2022
a584d1b
update Todo.java toString method
Jan 26, 2022
0b735ca
update Deadline.java toString method
Jan 26, 2022
716fed4
add Event.java to L4 folder
Jan 26, 2022
511d9cc
update Level4.java string outputs for todo, deadline and event tasks
Jan 26, 2022
a425c4f
update input.txt
Jan 26, 2022
0c6eb74
update runtest.sh to include path to main class on line 16
Jan 26, 2022
6966e73
update Level4.java removed final else condition
Jan 26, 2022
9052665
Move Deadline.java to L5 folder
Jan 28, 2022
401156d
Move Task.java to L5 folder
Jan 28, 2022
d36f543
Move Todo.java to L5 folder
Jan 28, 2022
2dbff74
Move Event.java to L5 folder
Jan 28, 2022
d6a00f5
add EmptyDescException.java
Jan 28, 2022
741d2b3
Level5.java: update elseif condition for "todo" to handle exception
Jan 28, 2022
b72cae3
Level5.java: Update if condition to identify whitespaces as empty input
Jan 28, 2022
d18b829
Level5.java: Add reply logic to respond to unrecognised tasks/words
Jan 28, 2022
184c942
Level5.java: Update greeting message to include instructions on usage
Jan 28, 2022
352f494
Copy Todo.java over to L6
Jan 28, 2022
ed56d8e
Copy Event.java over to L6
Jan 28, 2022
24820cd
Copy Deadline.java over to L6
Jan 28, 2022
3678626
Copy Task.java over to L6
Jan 28, 2022
9688666
Copy EmptyDescException.java over to L6
Jan 28, 2022
32fb5c7
Level6.java: Add the option to delete tasks from list
Jan 28, 2022
36a8484
update Task.java to include first letter of task as an attribute of task
Feb 16, 2022
9c60d76
update Todo.java constructor method
Feb 16, 2022
78f3666
update Deadline.java constructor and toString() method
Feb 16, 2022
fb4dc79
update Event.java constructor and toString() methods
Feb 16, 2022
58af730
move EmptyDescException.java from L6 to L7 folder
Feb 16, 2022
9e3a9f8
Add Siri.txt
Feb 16, 2022
78c8798
Update Level7.java to write/read to/from Siri.txt
Feb 17, 2022
f82b7f1
Neaten a few lines of code in Level7.java
Feb 17, 2022
6167f34
Add comment in Level7.java at line 35
Feb 17, 2022
dbcfa44
Update few lines of code in Level6.java
Feb 17, 2022
b2245c5
Copy Task.java from L6 to L8 folder
Feb 17, 2022
14510b3
Copy EmptyDescException.java over from L6 to L8 folder
Feb 17, 2022
4302353
Copy Todo.java over from L6 to L8 folder
Feb 17, 2022
bd33ba3
Overload Deadline.java constructor method to take in dates and dateTime
Feb 17, 2022
03f19fd
Overload Event.java constructor method inputs to accept date or dateTime
Feb 17, 2022
a6d5116
Update Level8.java to understand dates and times in deadline/event tasks
Feb 17, 2022
cac8234
Merge branch 'branch-Level-8'
Feb 17, 2022
2dbdb6f
Add Storage.java to load/save from/to the specified text file
Feb 18, 2022
ccd7b8a
Add TaskList.java to handle adding/deleting tasks in the list
Feb 18, 2022
b8083b5
Update EmptyDescException.java name to InvalidInputException.java
Feb 18, 2022
9f3f191
Add Ui.java to handle interactions with the user
Feb 18, 2022
e0fc56f
Add Parser.java to handle the logic of the program when interacting with
Feb 18, 2022
6d80fda
Add Command.java as super class to extract more classes for the diffe…
Feb 18, 2022
bfba6da
Add AddDeadlineCommand.java to create new deadline tasks to be added …
Feb 18, 2022
d3774e3
Update AddDeadlineCommand.java to add new line of code at the end of the
Feb 18, 2022
ffb4306
Add AddEventCommand.java & AddTodoCommand.java to create new tasks to be
Feb 18, 2022
9deaec7
Add MarkCommand.java & UnmarkCommand.java to mark/unmark tasks
Feb 18, 2022
23bfca1
Add DeleteCommand.java & ListCommand.java to delete & list tasks
Feb 18, 2022
1afd47a
Add ExitCommand.java to exit the program
Feb 18, 2022
d9d8baa
Move Deadline.java, Event.java, Todo.java & Task.java over to
Feb 18, 2022
a550e3c
Add Siri.java to call all necessary methods to get Siri program to run
Feb 18, 2022
9efd004
Add siri.txt file to read/write task details in
Feb 18, 2022
4a51887
Delete Siri Folder containing level1 to level8 of iP
Feb 19, 2022
2782ffe
Package all classes into siri in src/main/java/siri
Feb 19, 2022
e2881fe
Remove some lines of unreachable code
Feb 19, 2022
de14c4b
Add DeadlineTest.java, TodoTest.java & EventTest.java to test behavio…
Feb 19, 2022
fed9f60
ignore MANIFEST.MF file
Feb 19, 2022
5feebec
Add JavaDocs comments to the code
Feb 20, 2022
c22f0ba
Tweak the code to comply with coding standards
Feb 20, 2022
ce204e4
Add FindCommand.java to handle finding of tasks with specified keyword
Feb 20, 2022
3ba2263
Add Gradle support to iP
Feb 21, 2022
ba98855
Add a GUI to Siri
Feb 21, 2022
e33d706
Add Assertions to TaskList.java
Feb 21, 2022
e9ae6aa
Improve code quality
Feb 21, 2022
a27287d
Add C-Help extension to siri
Feb 21, 2022
827dfe9
Improve code quality
Feb 21, 2022
1b474c0
Merge pull request #2 from rcjj98/branch-A-Assertions
rcjj98 Feb 21, 2022
80d93fc
Merge branch 'master' into branch-C-Help
Feb 21, 2022
edd0771
Merge pull request #4 from rcjj98/branch-C-Help
rcjj98 Feb 21, 2022
c6950de
Update both user and program profile pictures
Feb 21, 2022
6cb24d9
Add Ui.png to docs directory
Feb 21, 2022
14676ee
Give credit to peer for code reusage
Feb 21, 2022
3abc3e2
Set theme jekyll-theme-tactile
rcjj98 Feb 21, 2022
7634d94
Add a User Guide
Feb 21, 2022
7c93904
Merge branch 'master' of https://github.com/rcjj98/ip
Feb 21, 2022
a5f267d
Set theme jekyll-theme-cayman
rcjj98 Feb 21, 2022
44ba29a
Update User Guide to be neater
Feb 21, 2022
2a6484b
Merge branch 'master' of https://github.com/rcjj98/ip
Feb 21, 2022
9d8c419
Update Storage.java to write/load to/from the correct directory
Feb 21, 2022
d8b449a
Update UserGuide
Feb 21, 2022
22e7c27
Update UserGuide
Feb 21, 2022
2e40a4a
Update UserGuide in README.md file
Feb 22, 2022
31bfaa0
Remove empty comment in Storage.java
Feb 22, 2022
a163a68
Add header comments
Mar 19, 2022
8ac15d1
Add header comments
Mar 19, 2022
dc126ca
Add header comments
Mar 19, 2022
b0d1b89
Update header comments to follow Javadoc comments coding standards
Mar 19, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bin/

/text-ui-test/ACTUAL.txt
text-ui-test/EXPECTED-UNIX.TXT
*.class
19 changes: 19 additions & 0 deletions Siri/L1/Level1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Scanner;

public class Level1 {

Choose a reason for hiding this comment

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

Perhaps adding a Javadoc for each class and public method?

Copy link

Choose a reason for hiding this comment

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

I agree that adding a Javadoc for each class and public method would allow the programme to be better understood

Copy link

Choose a reason for hiding this comment

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

It might be better to use a more intuitive class name here! I noticed the same issue in other places too.

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = " __________________________________________________\n";
System.out.println(line + " Hi there. I'm Siri \n" + " How may I help you? \n" + line);

while(true) {
String word = sc.next();
if (word.equals("bye")) { //print goodbye text
System.out.println(line + " Goodbye.\n" + line);
break;
} else { //print whatever user inputed
System.out.println(line + " " + word + "\n" + line);
}
}
}
}
29 changes: 29 additions & 0 deletions Siri/L2/Level2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Level2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<String> arrList = new ArrayList<String>();
String line = " __________________________________________________\n";
System.out.println(line + " Hi there. I'm Siri \n" + " How may I help you? \n" + line);

while(true) {
Copy link

Choose a reason for hiding this comment

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

Perhaps it would be better to put spaces before the parenthesis? in adherence to the java coding standard.

String word = sc.nextLine();
if (word.equals("bye")) { //print goodbye text
System.out.println(line + " Goodbye.\n" + line);
break;
} else if (word.equals("list")) { //print all elements in a list with index in front
System.out.print(line);
int s = arrList.size();
for(int i = 0; i < s; i++) {
System.out.println(" " + (i + 1) + ". " + arrList.get(i));
}
System.out.println(line);
} else { //print whatever user inputed with "added" infront
arrList.add(word);
System.out.println(line + " added: " + word + "\n" + line);
}
}
}
}
53 changes: 53 additions & 0 deletions Siri/L3/Level3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Level3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Task> arrList = new ArrayList<Task>();

Choose a reason for hiding this comment

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

Should arrList have a more meaningful name?

String line = " __________________________________________________\n"; //print a line before greeting message
System.out.println(line + " Hi there. I'm Siri \n" + " How may I help you? \n" + line);

while (true) { //will keep querying user for input until user inputs "bye" into system
String word = sc.next();
Copy link

Choose a reason for hiding this comment

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

Perhaps a more meaningful variable name would be easier to understand

if (word.equals("bye")) { //print goodbye text and exit while loop,stop scanner from scanning
System.out.println(line + " Goodbye.\n" + line);
break; //end while loop
} else if (word.equals("list")) { //print all elements in a list with index in front
System.out.println(line + " Tasks to do:");
int s = arrList.size();
for (int i = 0; i < s; i++) {
String currTask = arrList.get(i).toString();
System.out.println(" " + (i + 1) + "." + currTask);
}
System.out.println(line);
} else if (word.equals("mark")) {
int num = sc.nextInt();
int index = num - 1;
Task t = arrList.get(index);
t.markAsDone();
arrList.set(index, t);
System.out.println(line + " This task has been marked:\n"
+ " " + t.toString() + "\n"
+ line);
} else if (word.equals("unmark")) {
int num = sc.nextInt();
int index = num - 1;
Task t = arrList.get(index);
t.markAsNotDone();
arrList.set(index, t);
System.out.println(line + " This task has been unmarked:\n"
+ " " + t.toString() + "\n"
+ line);
} else { //print everything user inputed with "added: " infront
String restOfInput = sc.nextLine();
String taskToDo = word + restOfInput;
Task t = new Task(taskToDo);
arrList.add(t);
System.out.println(line + " This task has been added to your list:\n"
+ " added: " + taskToDo + "\n"
+ line);
}
}
}
}
28 changes: 28 additions & 0 deletions Siri/L3/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
public class Task {
String description;
boolean isDone;
Copy link

Choose a reason for hiding this comment

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

Nice naming boolean convention that follows recommended guidelines


public Task(String description) { //task constructor
this.description = description;
this.isDone = false; //initialise as false
}

public String getStatusIcon() { //will return either "X" or " " depending if task is done or not
return isDone
? "X" //if true mark with X
: " "; //if false do not mark, leave as empty space
}

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

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

public String toString() {
return "[" + this.getStatusIcon() + "] " + this.description;
}

}
16 changes: 16 additions & 0 deletions Siri/L4/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Deadline extends Task {

String deadline;

public Deadline(String description, String deadline) {
super(description);
this.deadline = deadline;
//find a way to scan deadline after description entered by user, maybe use the "/" as delimiter for the scanner?
}

@Override
public String toString() {
return "[D]" + "[" + this.getStatusIcon() + "]" + this.description + "(by:" + this.deadline + ")";
}

}
15 changes: 15 additions & 0 deletions Siri/L4/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Event extends Task {

String eventDate;

public Event(String description, String eventDate) {
super(description);
this.eventDate = eventDate;
}

@Override
public String toString() {
return "[E]" + "[" + this.getStatusIcon() + "]" + this.description + "(at:" + this.eventDate + ")";
Copy link

Choose a reason for hiding this comment

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

Since this line is quite long, any reason why you did not wrap it on a new line?

}

}
80 changes: 80 additions & 0 deletions Siri/L4/Level4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import java.util.Scanner;
import java.util.ArrayList;

public class Level4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Task> arrList = new ArrayList<Task>();
Copy link

Choose a reason for hiding this comment

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

perhaps changing the variable name to be more meaningful (e.g. taskList, tasks)?

String line = " __________________________________________________\n"; //print a line before greeting message
System.out.println(line + " Hi there. I'm Siri \n" + " How may I help you? \n" + line);

while (true) { //will keep querying user for input until user inputs "bye" into system
String word = sc.next();
if (word.equals("bye")) { //prints goodbye text and exit while loop,stop scanner from scanning
System.out.println(line + " Goodbye.\n" + line);
break; //end while loop
} else if (word.equals("list")) { //prints all elements in a list with index in front
System.out.println(line + " Tasks to do:");
int s = arrList.size();
for (int i = 0; i < s; i++) {
String currTask = arrList.get(i).toString();
System.out.println(" " + (i + 1) + "." + currTask);
}
System.out.println(line);
} else if (word.equals("mark")) { //marks the specified task with an "X"
int num = sc.nextInt();
int index = num - 1;
Task t = arrList.get(index);
t.markAsDone();
arrList.set(index, t);
System.out.println(line + " This task has been marked:\n "
+ t.toString() + "\n"
+ line);
} else if (word.equals("unmark")) { //unmarks the specified task
int num = sc.nextInt();
int index = num - 1;
Task t = arrList.get(index);
t.markAsNotDone();
arrList.set(index, t);
System.out.println(line + " This task has been unmarked:\n "
+ t.toString() + "\n"
+ line);
} else if (word.equals("todo")) { //creates todo task with "[T]" prefix and adds to the list
String restOfInput = sc.nextLine();
String taskToDo = restOfInput;
Todo t = new Todo(taskToDo);
arrList.add(t);
System.out.println(line + " This task has been added to your list:\n "
+ t.toString() + "\n" + "\n"
+ " Number of task(s) in your list: " + arrList.size() + "\n"
+ line);
} else if (word.equals("deadline")) {
//creates deadline task with "[D]" prefix and deadline postfix and adds to list
while (sc.hasNextLine()) {
String[] userInput = sc.nextLine().split("/by");
// The userInput array now contains [taskDescription, deadline]
Deadline deadLineTask = new Deadline(userInput[0], userInput[1]);
Copy link

Choose a reason for hiding this comment

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

Good job on the clean code, however it might be better to avoid using magic numbers for better readability!

arrList.add(deadLineTask);
System.out.println(line + " This task has been added to your list:\n "
+ deadLineTask.toString() + "\n" + "\n"
+ " Number of task(s) in your list: " + arrList.size() + "\n"
+ line);
break;
}
} else if (word.equals("event")) {
//creates event task with "[E]" prefix and event date postfix and adds to list
while (sc.hasNextLine()) {
String[] userInput = sc.nextLine().split("/at");
// The userInput array now contains [taskDescription, event date]
Event eventTask = new Event(userInput[0], userInput[1]);
arrList.add(eventTask);
System.out.println(line + " This task has been added to your list:\n "
+ eventTask.toString() + "\n" + "\n"
+ " Number of task(s) in your list: " + arrList.size() + "\n"
+ line);
break;
}
} else { } //do nothing

Choose a reason for hiding this comment

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

Maybe the last else { } can be omitted?

}
}
}
29 changes: 29 additions & 0 deletions Siri/L4/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class Task {
String description;
boolean isDone;

public Task(String description) { //task constructor
this.description = description;
this.isDone = false; //initialise as false
}

public String getStatusIcon() { //will return either "X" or " " depending if task is done or not
Copy link

Choose a reason for hiding this comment

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

it's good that you use verb/action to name the methods!

return isDone
? "X" //if true mark with X
: " "; //if false do not mark, leave as empty space
}

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

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

@Override
public String toString() {
return "[" + this.getStatusIcon() + "] " + this.description;
}

}
12 changes: 12 additions & 0 deletions Siri/L4/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class Todo extends Task {

public Todo(String description) {
super(description);
}

@Override
public String toString() {
return "[T]" + "[" + this.getStatusIcon() + "]" + this.description;
}

}
16 changes: 16 additions & 0 deletions Siri/L5/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
public class Deadline extends Task {

String deadline;

public Deadline(String description, String deadline) {
super(description);
this.deadline = deadline;
//find a way to scan deadline after description entered by user, maybe use the "/" as delimiter for the scanner?
}

@Override
public String toString() {
return "[D]" + "[" + this.getStatusIcon() + "]" + this.description + "(by:" + this.deadline + ")";
}

}
13 changes: 13 additions & 0 deletions Siri/L5/EmptyDescException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class EmptyDescException extends Exception {

private String message;

EmptyDescException(String message) {
super(message);
this.message = message;
}

public String toString() {
return this.message;
}
}
15 changes: 15 additions & 0 deletions Siri/L5/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public class Event extends Task {

String eventDate;

public Event(String description, String eventDate) {
super(description);
this.eventDate = eventDate;
}

@Override
public String toString() {
return "[E]" + "[" + this.getStatusIcon() + "]" + this.description + "(at:" + this.eventDate + ")";
}

}
Loading