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

[Cao] iP #466

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
a0828cb
Added features for Greet, Echo and Exit
Aug 20, 2020
2a955ed
Added features of Level-2, Add and List
Aug 20, 2020
2960cdb
Added done feature, but not achieved
Aug 20, 2020
e6f5a1b
Add package main.java
Aug 30, 2020
d619ffa
Adjusted the robot's responding style
Aug 30, 2020
7a01956
Added a Task class, but did not merge it with the main class Duke.java
Aug 30, 2020
23ff51e
added printDescription() method to Task class
Aug 30, 2020
aaf0db0
Merged Task.java class with Duke.java class, completed features for l…
Aug 30, 2020
b989315
Added classes Todo, Deadline, Event.
Aug 30, 2020
46c1cf5
Added feature for Automated Text UI Testing
Aug 30, 2020
bf02861
Added feature for Exception handling
Sep 2, 2020
9ed888d
Handled exceptions for deadline
Sep 3, 2020
4630050
updated exceptions handling for event
Sep 3, 2020
eccd4bd
Finished delete function
Sep 3, 2020
518a798
Handled exception for Done
Sep 3, 2020
3d92ca2
Updated exception handling for delete operation
Sep 3, 2020
488eaec
Saved the list of tasks in a txt. file. Every time will load the data…
Sep 7, 2020
74ae682
solved the bug when the command.txt does not exist.
Sep 7, 2020
fc5812c
Stored Deadline data as java.time.LocalDate
Sep 9, 2020
fd6a9b3
Merge branch 'branch-Level-7'
Sep 9, 2020
9528c06
Merge branch 'branch-Level-8'
Sep 9, 2020
b6efb63
Revise the OOP of the project
Ringo1225 Sep 9, 2020
ecd9609
Add Junit test cases
Ringo1225 Sep 9, 2020
7dbaa04
add jar file on github
Ringo1225 Sep 9, 2020
ad53f61
Adds java docs
Ringo1225 Sep 9, 2020
2a51b71
Tweak the code to comply with a coding standard
Ringo1225 Sep 9, 2020
18690fd
Add find feature
Ringo1225 Sep 9, 2020
48642d3
Merge branch 'branch-A-JavaDoc'
Ringo1225 Sep 9, 2020
500c754
Merge branch 'branch-A-CodingStandard'
Ringo1225 Sep 9, 2020
4e5da11
Merge branch 'branch-Level-9'
Ringo1225 Sep 9, 2020
04d380f
Use Gradle to automate some of the build tasks of the project.
Ringo1225 Sep 9, 2020
da7df49
Merge branch 'branch-A-Gradle'
Ringo1225 Sep 9, 2020
e9dc761
Revise the project structure
Ringo1225 Sep 9, 2020
d743259
Revise project structure
Ringo1225 Sep 13, 2020
e9542b0
Edit build.gradle
Ringo1225 Sep 13, 2020
88955d9
Add some GUI feature
Ringo1225 Sep 16, 2020
64d7ccd
Improve GUI
Ringo1225 Sep 16, 2020
a2fe141
Restructure Parser
Ringo1225 Sep 16, 2020
03db3d5
fix bug for some operation
Ringo1225 Sep 17, 2020
6177d62
Merge branch 'master' into branch-GUI
Ringo1225 Sep 17, 2020
6ed168a
Finish GUI feature
Ringo1225 Sep 17, 2020
6703d18
Restructure project
Ringo1225 Sep 17, 2020
4867fea
Add FXML
Ringo1225 Sep 17, 2020
600c0da
Merge branch 'branch-GUI'
Ringo1225 Sep 17, 2020
31edbef
Try to create a jar file
Ringo1225 Sep 17, 2020
c24a998
Add assertions
Ringo1225 Sep 18, 2020
7dd194a
Improve code quality
Ringo1225 Sep 18, 2020
a99084c
Add feature: FixedDurationTasks
Ringo1225 Sep 18, 2020
3f9875b
Merge pull request #3 from Ringo1225/branch-A-Assertions
Ringo1225 Sep 18, 2020
2b5a07c
Merge branch 'master' of https://github.com/Ringo1225/ip
Ringo1225 Sep 18, 2020
4e15055
Merge branch 'master' into branch-A-CodeQuality
Ringo1225 Sep 18, 2020
ce96300
Merge branch 'branch-A-CodeQuality' into branch-B-FixedDurationTasks
Ringo1225 Sep 18, 2020
19baa19
Merge pull request #1 from Ringo1225/branch-A-CodeQuality
Ringo1225 Sep 18, 2020
25b7998
Merge branch 'master' of https://github.com/Ringo1225/ip
Ringo1225 Sep 18, 2020
1e4cdf2
Merge branch 'master' into branch-B-FixedDurationTasks
Ringo1225 Sep 18, 2020
1046b5e
Merge pull request #2 from Ringo1225/branch-B-FixedDurationTasks
Ringo1225 Sep 18, 2020
19b36fb
Merge branch 'master' of https://github.com/Ringo1225/ip
Ringo1225 Sep 18, 2020
cf73057
Add reuse acknowlegement
Ringo1225 Sep 18, 2020
4037756
Add Ui.png
Ringo1225 Sep 18, 2020
1655726
Update user guide
Ringo1225 Sep 18, 2020
4b7aeb1
Set theme jekyll-theme-minimal
Ringo1225 Sep 18, 2020
74aa3da
Revise user guide
Ringo1225 Sep 18, 2020
cbb962b
Merge branch 'master' of https://github.com/Ringo1225/ip
Ringo1225 Sep 18, 2020
3457ff4
Revise User Guide
Ringo1225 Sep 18, 2020
8e00007
Revise User Guide
Ringo1225 Sep 18, 2020
9a57b7a
Set theme jekyll-theme-midnight
Ringo1225 Sep 18, 2020
5513e6d
revise build.gradle, generate a jar file
Ringo1225 Sep 18, 2020
bd54f7a
Merge branch 'master' of https://github.com/Ringo1225/ip
Ringo1225 Sep 18, 2020
777b9e0
update jar file version
Ringo1225 Sep 18, 2020
1615411
Set theme jekyll-theme-minimal
Ringo1225 Oct 10, 2020
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
16 changes: 16 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main.java;

public class Deadline extends Task {
protected String deadline;

Choose a reason for hiding this comment

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

Suggest using private keyword instead of protected.


public Deadline(String description, String deadline) {
super(description);
this.deadline = deadline;
}

@Override
public void printDescription() {
System.out.println("[D][" + getStatusIcon()
+ "] " + description + "(by:" + deadline + ")");
}
}
95 changes: 94 additions & 1 deletion src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,103 @@
package main.java;

import java.util.Scanner;
import java.util.ArrayList;

public class Duke {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| _ \\ _ _| | _____\n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
System.out.println(" ____________________________________________________________");
System.out.println(" Hello! I'm Duke\n What can I do for you?");

Choose a reason for hiding this comment

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

different parts of the code can be grouped together as a method, make it easier for abstraction.

System.out.println(" ____________________________________________________________\n");

ArrayList<Task> taskList = new ArrayList<Task>();

while (true) {
String command = sc.next();
switch(command) {
case "bye":
System.out.println(" ____________________________________________________________");
System.out.println(" Bye. Hope to see you again soon!");
System.out.println(" ____________________________________________________________\n");
return;
case "list":
System.out.println(" ____________________________________________________________");
System.out.println(" Here are the tasks in your list:");
for (int i = 0; i < taskList.size(); i++) {
System.out.print(" " + (i + 1) + ".");
taskList.get(i).printDescription();
}
System.out.println(" ____________________________________________________________\n");
break;
case "done":
int index = sc.nextInt();
Task currentTask = taskList.get(index - 1);
currentTask.markAsDone();
System.out.println(" ____________________________________________________________");
System.out.println(" Nice! I've marked this task as done:");
System.out.print(" ");
currentTask.printDescription();
System.out.println(" ____________________________________________________________\n");
break;
case "todo":
String todoDescription = sc.nextLine();
Todo todo = new Todo(todoDescription);
taskList.add(todo);
System.out.println(" ____________________________________________________________");
System.out.println(" Got it. I've added this task:");
System.out.print(" ");
todo.printDescription();
System.out.println(" Now you have " + taskList.size() + " tasks in the list.");
System.out.println(" ____________________________________________________________\n");
break;
case "deadline":
String deadlineDescription = "";
while (!sc.hasNext("/by")) {
deadlineDescription += sc.next();
deadlineDescription += " ";
}
sc.next("/by");
String time = sc.nextLine();
Deadline deadline = new Deadline(deadlineDescription, time);
taskList.add(deadline);
System.out.println(" ____________________________________________________________");
System.out.println(" Got it. I've added this task:");
System.out.print(" ");
deadline.printDescription();
System.out.println(" Now you have " + taskList.size() + " tasks in the list.");
System.out.println(" ____________________________________________________________\n");
break;
case "event":
String eventDescription = "";
while (!sc.hasNext("/at")) {
eventDescription += sc.next();
eventDescription += " ";
}
sc.next("/at");
String date = sc.nextLine();
Event event = new Event(eventDescription, date);
taskList.add(event);
System.out.println(" ____________________________________________________________");
System.out.println(" Got it. I've added this task:");
System.out.print(" ");
event.printDescription();
System.out.println(" Now you have " + taskList.size() + " tasks in the list.");
System.out.println(" ____________________________________________________________\n");
break;
default:
String task = sc.nextLine();
taskList.add(new Task(command + task));
System.out.println(" ____________________________________________________________");
System.out.println(" added: " + command + task);
System.out.println(" ____________________________________________________________\n");
break;
}
}
}
}
16 changes: 16 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main.java;

public class Event extends Task {
protected String time;

Choose a reason for hiding this comment

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

same suggestion as deadline


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

@Override
public void printDescription() {
System.out.println("[E][" + getStatusIcon()
+ "] " + description + "(at:" + time + ")");
}
}
23 changes: 23 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main.java;

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

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

public String getStatusIcon() {
return (isDone ? "\u2713" : "\u2718");
}

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

public void printDescription() {
System.out.println("[" + getStatusIcon() + "] " + description);
}
}
12 changes: 12 additions & 0 deletions src/main/java/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main.java;

public class Todo extends Task {
public Todo(String description) {
super(description);
}

@Override
public void printDescription() {
System.out.println("[T][" + getStatusIcon() + "]" + description);
}
}
67 changes: 66 additions & 1 deletion text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
Hello from
____ _
| _ \ _ _| | _____
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|

____________________________________________________________
Hello! I'm Duke
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.
____________________________________________________________

____________________________________________________________
Nice! I've marked this task as done:
[T][?] read book
____________________________________________________________

____________________________________________________________
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)
____________________________________________________________

____________________________________________________________
Nice! I've marked this task as done:
[E][?] project meeting (at: Aug 6th 2-4pm)
____________________________________________________________

____________________________________________________________
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)
____________________________________________________________

____________________________________________________________
Got it. I've added this task:
[T][?] buy bread
Now you have 4 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][?] buy bread
____________________________________________________________

____________________________________________________________
Bye. Hope to see you again soon!
____________________________________________________________

19 changes: 19 additions & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
todo read book

deadline return book /by June 6th

event project meeting /at Aug 6th 2-4pm

done 1

list

done 3

list

todo buy bread

list

bye
4 changes: 2 additions & 2 deletions 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 main.java.Duke < input.txt > ACTUAL.TXT

# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT
Expand All @@ -35,4 +35,4 @@ then
else
echo "Test result: FAILED"
exit 1
fi
fi