[Tai Kah Kiang] iP#70
Conversation
7d1cef2 to
e86117d
Compare
yanjie1017
left a comment
There was a problem hiding this comment.
Great work in overall! Levels of abstraction are present too.
| } | ||
|
|
||
| //main | ||
| public static void run (String line) { |
There was a problem hiding this comment.
The title of this method can be more informative.
| String addInfo = words.size() >= 2 ? words.get(1) : null; | ||
|
|
||
| switch (type) { | ||
| case "todo": |
There was a problem hiding this comment.
Can consider extracting out some methods or sub-methods to a new class (eg. TaskManager, TaskList) to manage any functions related to Task
cczhouqi
left a comment
There was a problem hiding this comment.
Overall, I think your code is clear and easy to follow👍🏻 There are only some minor formatting things that you may want to improve on.
| } | ||
|
|
||
| //command methods | ||
| public static void hello() { |
There was a problem hiding this comment.
I like how you abstracted the hello message (and other tasks), that makes your main method clean and clear :D
| public static void run (String line) { | ||
| ArrayList<String> words = processInput(line, " "); | ||
| String command = words.get(0); | ||
| String description = words.size()>= 2 ? words.get(1) : null; |
There was a problem hiding this comment.
Format can be more consistent here: you may want to add a space between “word.size()” and “>=“.
|
|
||
| hello(); | ||
|
|
||
| Scanner sc = new Scanner (System.in); |
There was a problem hiding this comment.
Maybe the name “sc” can be more informative.
|
|
||
| public Event(String name, String time) { | ||
| super(name); | ||
| this.time= time; |
There was a problem hiding this comment.
Same as in Duke.java line 94, you may want to add a space between “this.time” and “=“ to make it more consistent.
khseah
left a comment
There was a problem hiding this comment.
Overall clean and easy to read. However I feel the code can be more consistent as some methods and blocks of code are separated by a new line while others are not.
|
|
||
| public Deadline(String name, String deadline) { | ||
| super(name); | ||
| this.deadline= deadline; |
There was a problem hiding this comment.
| this.deadline= deadline; | |
| this.deadline = deadline; |
Maybe add a space to improve readability. I noticed this in other parts of the code as well
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[D]" + super.toString() + String.format("(%s)", this.deadline) ; |
There was a problem hiding this comment.
| return "[D]" + super.toString() + String.format("(%s)", this.deadline) ; | |
| return "[D]" + super.toString() + String.format("(%s)", this.deadline); |
Not sure why there is a space before ;
| if (divider != -1) { | ||
| words.set(0, line.substring(0, divider)); | ||
| words.add(line.substring(divider+1)); |
| printWithDivider(task.toString()); | ||
| } | ||
|
|
||
| //main |
There was a problem hiding this comment.
This comment isn't really helpful. Maybe provide more details?
| @@ -0,0 +1,14 @@ | |||
| public class Event extends Task{ | |||
|
|
|||
There was a problem hiding this comment.
This class has a empty line before its attributes. However I noticed other classes do not have this empty line. Try and make it more consistent
Merging from level 5, no ff
| public class Duke { | ||
| public static void main(String[] args) { | ||
|
|
||
| //fields |
There was a problem hiding this comment.
This comment is not very helpful in providing further explanation on how the variable is used. It can be omitted.
| public static void run(String line) throws DukeException { | ||
| ArrayList<String> words = IOMethods.splitToTwo(line, " "); | ||
| String command = words.get(0); | ||
| String description = words.size()>= 2 ? words.get(1) : null; |
There was a problem hiding this comment.
2 is a magic number that you could avoid. Consider using named constants instead.
|
|
||
|
|
There was a problem hiding this comment.
Remove empty lines like these to improve code readability.
| String taskType = input.substring(indexOfSpace + 2, indexOfSpace+3); | ||
| String status = input.substring(indexOfSpace + 5, indexOfSpace + 6); | ||
| String nameAndDate = input.substring(indexOfSpace+ 7); |
There was a problem hiding this comment.
There are many magic numbers here which you can avoid.
| System.out.println(breakLine); | ||
| } | ||
|
|
||
| public static void errorHandler(String input) throws DukeException { |
There was a problem hiding this comment.
This is method is quite long (>30 LoC). Consider applying SLAP for each of the commands for further abstraction.
| case "todo": | ||
| case "event": | ||
| case "deadline": |
There was a problem hiding this comment.
You can refer to switch case statement layout in the Java coding standards and add fallthrough comments here.
| if (command.equals("event") || command.equals("deadline")) { | ||
| int indexOfSlash = input.indexOf("/"); | ||
| String date = indexOfSlash == -1 ? "" : input.substring(indexOfSlash); | ||
| if (date.length() <= 1) { | ||
| String errorMsg = String.format("%s requires a valid date in the format taskName /date\n", command); | ||
| throw new DukeException(errorMsg); | ||
| } | ||
| } | ||
| } |
Branch level 8
Completed until Week 3 (Level 3, then A- Coding Standard)
Has greetings, todo, and toggle complete