-
Notifications
You must be signed in to change notification settings - Fork 193
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
[wingho]IP #196
base: master
Are you sure you want to change the base?
[wingho]IP #196
Changes from 1 commit
cfa100b
58398a4
7b1d074
1d74b39
eed209d
f4fecb4
b8ad62d
37abf0d
1e6963b
2f491b7
4a08901
50ed25d
64b7752
2305316
57771c8
a9d7713
1a2a6ac
c383114
5ee47d4
6ee2be3
f714fce
ec11a9f
6d21d77
8565495
80e1c4e
71fb4c5
cf3394a
3f53d4e
30a5c96
1f8f273
4fb78e6
05c358f
9a88e1b
668659b
8c59d4d
9060af4
dc1ab66
2b9947c
6ca401f
27f1319
1c84ea0
899cb14
1915741
2bb73dd
88be32e
6ffc9fd
fd4bc0a
125df38
2ecd0a6
d22def0
5d5f795
1bbc6f5
7022461
78d2e29
15cfa13
b349f2e
6a5eff9
0303cbe
52b947b
b097c6f
025d7c0
c922374
ecceb76
8e59389
887ddf1
b184fca
2989450
d07b2aa
bd7aca4
f3317e1
264344e
21ea138
19b892c
8e97fa8
41d7353
5d3bffc
4339745
7576a85
3f424fc
5cbdada
0ec1b61
28c7be4
e4d14a7
4054b00
bc4554c
1816abe
e29bcf7
cee51f8
bba48ca
f2c2a13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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 + ")"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be more readable if you add the @OverRide before overriding toString() method. |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to follow the coding standard where there is a space between the class name and the {. The same goes for methods. |
||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,19 +26,36 @@ public static void main(String[] args) { | |||||
break; | ||||||
}else if(echoLower.equals("list")) { | ||||||
for(int i = 0; i < listIndex; i ++){ | ||||||
System.out.println((i + 1) + ". ["+ list[i].getStatusIcon() + "] " + list[i].getDescription()); | ||||||
System.out.println((i + 1) + ". " + list[i].toString()); | ||||||
} | ||||||
}else if(echoLower.equals("done")) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a very small issue of coding standard. Based on Checkstyle, there should be a space before
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please leave spaces for the if-else blocks, abiding by the coding standard. |
||||||
int taskDone = Integer.parseInt(in.nextLine()); | ||||||
list[taskDone-1].markAsDone(); | ||||||
for(int i = 0; i < listIndex; i ++){ | ||||||
System.out.println((i + 1) + ". ["+ list[i].getStatusIcon() + "] " + list[i].getDescription()); | ||||||
list[taskDone - 1].markAsDone(); | ||||||
for (int i = 0; i < listIndex; i++) { | ||||||
System.out.println((i + 1) + ". " + list[i].toString()); | ||||||
} | ||||||
}else { | ||||||
Task t = new Task(echoLower); | ||||||
}else if(echoLower.startsWith("event")){ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a small issue, I think there should be spaces before "{" and after "}" |
||||||
int startOfTime = echoLower.indexOf("/"); | ||||||
String description = echoLower.substring(6,startOfTime); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is better to avoid magic number, e.g., 6 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is better to avoid magic numbers, e.g., 6 |
||||||
String time = echoLower.substring(startOfTime + 1); | ||||||
Task t = new Event(description, time); | ||||||
list[listIndex] = t; | ||||||
listIndex += 1; | ||||||
System.out.println("Got it. I've added this task: " + System.lineSeparator() + t.toString() + System.lineSeparator() + "Now you have " + listIndex+" tasks in the list."); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are more than 120 characters in this line, maybe you could split it into 2 lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree |
||||||
}else if (echoLower.startsWith("todo")){ | ||||||
String description = echoLower.substring(5); | ||||||
Task t = new Todo(description); | ||||||
list[listIndex] = t; | ||||||
listIndex += 1; | ||||||
System.out.println("Got it. I've added this task: " + System.lineSeparator() + t.toString() + System.lineSeparator() + "Now you have " + listIndex +" tasks in the list."); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are more than 120 characters in this line, maybe you could split it into 2 lines? |
||||||
}else if(echoLower.startsWith("deadline")){ | ||||||
int startOfDeadline = echoLower.indexOf("/"); | ||||||
String description = echoLower.substring(9,startOfDeadline); | ||||||
String deadline = echoLower.substring(startOfDeadline + 1); | ||||||
Task t = new Deadline(description, deadline); | ||||||
list[listIndex] = t; | ||||||
listIndex += 1; | ||||||
System.out.println("____________________________________________________________\n" + "added: " + echo + System.lineSeparator() + "____________________________________________________________"); | ||||||
System.out.println("Got it. I've added this task: " + System.lineSeparator() + t.toString() + System.lineSeparator() + "Now you have " + listIndex +" tasks in the list."); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are more than 120 characters in this line, maybe you could split it into 2 lines? |
||||||
} | ||||||
} | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
public class Event extends Task{ | ||
protected String time; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better to make it a private string to ensure data hiding in encapsulation. |
||
public Event(String description, String time){ | ||
super(description); | ||
this.time = time; | ||
} | ||
public String toString(){ | ||
return "[E]" + super.toString() + "(at:" + time + ")"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,4 +15,7 @@ public String getDescription(){ | |||||
public String getStatusIcon(){ | ||||||
return(isDone?"X":" "); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you could consider using the full if statement. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the coding standard in leaving spaces. |
||||||
} | ||||||
public String toString(){ | ||||||
return "[" + getStatusIcon() + "]" + description; | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
public class Todo extends Task{ | ||
|
||
public Todo(String description){ | ||
super(description); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "[T]" + super.toString(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to have a blank line in between variables declared and method, as well as between two methods.