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

[Hong Jiancheng] iP #4

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
791aefd
level 0. Greet
HongJiancheng Aug 21, 2020
048cb6a
level 1. Greet, Echo, Exit
HongJiancheng Aug 21, 2020
cf5b4ce
level 2. Add, List
HongJiancheng Aug 21, 2020
950a7a7
level 3. Mark as Done
HongJiancheng Aug 21, 2020
656f8cf
level 4. ToDo, Event, Deadline
HongJiancheng Aug 21, 2020
8f34de9
A-TextUiTesting: Automated Text UI Testing
HongJiancheng Aug 26, 2020
86fa885
Level 5. Handle Errors and A-Package
HongJiancheng Sep 2, 2020
8613910
A-CodeQuality: Improve Code Quality
HongJiancheng Sep 2, 2020
19fa770
A-AbstractClasses: Use Abstract Classes
HongJiancheng Sep 2, 2020
b694977
Merge branch 'branch-Level-5'
HongJiancheng Sep 2, 2020
462c6d8
Merge branch 'master' into branch-A-CodeQuality
HongJiancheng Sep 4, 2020
d7907b7
Level 6. Delete
HongJiancheng Sep 4, 2020
f28ffc3
Merge pull request #1 from pigoliver/branch-Level-6
HongJiancheng Sep 4, 2020
4c1d2f5
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Sep 4, 2020
e968359
Level 7. Save
HongJiancheng Sep 11, 2020
5b6156c
A-JavaDoc: Add JavaDoc comments
HongJiancheng Sep 11, 2020
2c01efb
A-Jar: created a jar file
HongJiancheng Sep 11, 2020
6c3b173
Merge branch 'branch-Level-7'
HongJiancheng Sep 11, 2020
d6f673c
Merge branch 'branch-A-JavaDoc'
HongJiancheng Sep 11, 2020
44ef7b3
A-MoreOOP: Use More OOP
HongJiancheng Sep 17, 2020
c6212de
A-Packages
HongJiancheng Sep 17, 2020
6e26484
Level 9. Find
HongJiancheng Sep 17, 2020
2aa78f8
A-JUnit: Add JUnit Tests
HongJiancheng Sep 18, 2020
ffae5d3
Merge pull request #2 from pigoliver/branch-Level-9
HongJiancheng Sep 18, 2020
97b1a6a
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Sep 18, 2020
6c0d23e
Merge pull request #3 from pigoliver/branch-A-JUnit
HongJiancheng Sep 18, 2020
3718d1f
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Sep 18, 2020
8c83c57
Merge branch 'branch-A-Packages'
HongJiancheng Sep 18, 2020
d7e32d6
A-AbstractClasses: to add branch
HongJiancheng Sep 18, 2020
a3aedb4
Merge branch 'branch-A-AbstractClasses'
HongJiancheng Sep 18, 2020
0dc4f8f
Level-8: Dates and Times
HongJiancheng Sep 18, 2020
cec7c71
Merge pull request #4 from pigoliver/branch-Level-8
HongJiancheng Sep 18, 2020
ba07565
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Sep 18, 2020
ec9804c
A-UserGuide: Add a User Guide
HongJiancheng Sep 27, 2020
4ac241a
A-Release: Repair a date saving bug discovered from testing
HongJiancheng Sep 27, 2020
989c047
Edit File Directory Handling Error
HongJiancheng Sep 27, 2020
b83a165
A-Gradle
HongJiancheng Jan 18, 2021
f8bf871
Merge pull request #5 from HongJiancheng/branch-A-Gradle
HongJiancheng Jan 18, 2021
a32faa2
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Jan 18, 2021
ed65a3c
A-CheckStyle
HongJiancheng Jan 26, 2021
9308640
Merge pull request #6 from HongJiancheng/branch-A-StricterCodingStandard
HongJiancheng Jan 26, 2021
c867709
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Jan 26, 2021
d9a97b5
Level-10
HongJiancheng Jan 27, 2021
b5b5b60
Merge pull request #7 from HongJiancheng/branch-Level-10
HongJiancheng Jan 27, 2021
929f541
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Jan 27, 2021
4d2f300
Updated GUI with better view
HongJiancheng Jan 30, 2021
9d41a6e
Resolve file access issue
HongJiancheng Jan 31, 2021
588f009
A-CI
HongJiancheng Feb 3, 2021
0859dd2
Merge pull request #8 from HongJiancheng/branch-A-CI
HongJiancheng Feb 3, 2021
e17ae6d
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Feb 3, 2021
6469034
Debug CI
HongJiancheng Feb 3, 2021
4c52851
Edit gradlew executable bit
HongJiancheng Feb 3, 2021
52dd10b
Checkstyle error changed
HongJiancheng Feb 3, 2021
9761109
BCD-Extension: Duplicate Check
HongJiancheng Feb 4, 2021
c93dff9
Checkstyle resolved
HongJiancheng Feb 4, 2021
e3ede5a
Merge pull request #10 from HongJiancheng/branch-BCD-Extension
HongJiancheng Feb 4, 2021
6112b70
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Feb 4, 2021
34f07b5
Better GUI with higher coding standard
HongJiancheng Feb 14, 2021
59e1bf5
Merge pull request #11 from HongJiancheng/branch-A-HigherCodingQuality
HongJiancheng Feb 14, 2021
184fc9b
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Feb 14, 2021
15c22cd
Final Enhancement with help command and duplicate command improvement
HongJiancheng Feb 24, 2021
6beb872
Merge pull request #12 from HongJiancheng/branch-Final-Enhancement
HongJiancheng Feb 24, 2021
725c21b
Merge branch 'master' of https://github.com/pigoliver/ip
HongJiancheng Feb 24, 2021
3474ef8
Update project documents
HongJiancheng Feb 24, 2021
7533eed
Merge pull request #13 from HongJiancheng/branch-Update-Website
HongJiancheng Feb 24, 2021
3754307
Update DeveloperGuide.md
HongJiancheng Feb 24, 2021
e10a5da
Update DeveloperGuide.md
HongJiancheng Feb 24, 2021
e9b83dc
Set theme jekyll-theme-slate
HongJiancheng Feb 24, 2021
dced765
Delete Ui.PNG
HongJiancheng Feb 24, 2021
7af9f3b
Add files via upload
HongJiancheng Feb 24, 2021
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
32 changes: 28 additions & 4 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void getCommand(String input,Storage store, Ui ui){
ui.printLine();
ui.indentPrint("Here are the tasks in your list:");
for(int i=0;i<store.getSize();i++){
ui.indentPrint((i+1)+". "+ui.taskToString(store.getTask(i)));
ui.indentPrint((i+1)+". "+store.getTask(i).toString());
}
ui.printLine();
break;
Expand All @@ -26,14 +26,38 @@ public void getCommand(String input,Storage store, Ui ui){
store.setDoneAt(index-1);
ui.printLine();
ui.indentPrint("Nice! I've marked this task as done: ");
ui.indentPrint(" "+ui.taskToString(store.getTask(index-1)));
ui.indentPrint(" "+store.getTask(index-1).toString());
ui.printLine();
break;
case "todo":
store.addToDoToTemp(others);
ui.printLine();
ui.indentPrint("Got it. I've added this task: ");
ui.indentPrint(" "+store.getTask(store.getSize()-1).toString());
ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
ui.printLine();
break;
case "deadline":
store.addDeadlineToTemp(others);
ui.printLine();
ui.indentPrint("Got it. I've added this task: ");
ui.indentPrint(" "+store.getTask(store.getSize()-1).toString());
ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
ui.printLine();
break;
case "event":
store.addEventToTemp(others);
ui.printLine();
ui.indentPrint("Got it. I've added this task: ");
ui.indentPrint(" "+store.getTask(store.getSize()-1).toString());
ui.indentPrint( "Now you have "+store.getSize()+" tasks in the list.");
ui.printLine();
break;
Copy link
Author

Choose a reason for hiding this comment

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

I felt these codes are highly repeated with each other, but don't know how to make it nicer.

Any suggestions?

Copy link

Choose a reason for hiding this comment

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

I would consolidate the steps (print the message, print the task) and write a new function to handle it

Copy link
Author

Choose a reason for hiding this comment

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

Sounds great! I will try to work in this direction.

default:
ui.printLine();
store.addToTemp(input);
ui.indentPrint("added: "+input);
ui.indentPrint("unknown command, please try again");
ui.printLine();
break;
}
}
}
22 changes: 20 additions & 2 deletions src/main/java/Storage.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import Tasks.Deadline;
import Tasks.Event;
import Tasks.Task;
import Tasks.Todo;

import java.util.ArrayList;

public class Storage {
private ArrayList<Task> tempStorage;
private boolean isExit;
Storage(){
tempStorage = new ArrayList<Task>(100);
tempStorage = new ArrayList<>(100);
isExit = false;
}
public void addToTemp(String toAdd){
public void addTaskToTemp(String toAdd){
tempStorage.add(new Task(toAdd));
}
public void addToDoToTemp(String toAdd){
tempStorage.add(new Todo(toAdd));
}
public void addDeadlineToTemp(String toAdd){
String description = toAdd.split(" /by ")[0];
String by = toAdd.split(" /by ")[1];
tempStorage.add(new Deadline(description,by));
}
public void addEventToTemp(String toAdd){
String description = toAdd.split(" /at ")[0];
String at = toAdd.split(" /at ")[1];
tempStorage.add(new Event(description,at));
}
public int getSize(){
return tempStorage.size();
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/Tasks/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Tasks;

public class Deadline extends Task {
protected String by;
public Deadline(String description, String by){
super(description);
this.by=by;
}
public String toString(){
return "[D]" + super.toString() + " (by: " + by + ")";
}
}
12 changes: 12 additions & 0 deletions src/main/java/Tasks/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Tasks;

public class Event extends Task {
protected String at;
public Event(String description, String at){
super(description);
this.at = at;
}
public String toString(){
return "[E]" + super.toString() + " (at: " + at + ")";
}
}
5 changes: 5 additions & 0 deletions src/main/java/Task.java → src/main/java/Tasks/Task.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package Tasks;

public class Task {
protected String description;
protected boolean isDone;
Expand All @@ -22,4 +24,7 @@ public void setNotDone(){
public String getDescription(){
return this.description;
}
public String toString(){
return "["+getStatusIcon()+"]"+" "+getDescription();
}
}
10 changes: 10 additions & 0 deletions src/main/java/Tasks/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package Tasks;

public class Todo extends Task {
public Todo(String description){
super(description);
}
public String toString(){
return "[T]" + super.toString();
}
}
3 changes: 0 additions & 3 deletions src/main/java/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ public void greetUser(){
indentPrint("What can I do for you?");
printLine();
}
public String taskToString(Task toPrint){
return "["+toPrint.getStatusIcon()+"]"+" "+toPrint.getDescription();
}
public void byeToUser(){
printLine();
indentPrint("Bye. Hope to see you again soon!");
Expand Down