Mor Ben Ami#66
Conversation
|
|
||
|
|
||
| public List() { | ||
| tasks = new Task[100]; |
There was a problem hiding this comment.
The use of magic number here is ambiguous, feel free to consider using a constant
| @@ -0,0 +1,33 @@ | |||
| public class Task { | |||
| private String description; | |||
| private boolean marking; | |||
There was a problem hiding this comment.
boolean values should be named to sound like booleans, consider "isMarked" or "isFinished"
| marking = false; | ||
| } | ||
|
|
||
| public void markDone() { |
There was a problem hiding this comment.
Perhaps it would be better to have a method to print the string, rather than having a function that does both setting the boolean and printing
| line = in.nextLine(); | ||
| while (!line.equals("bye")){ | ||
| words = line.split(" "); | ||
| if (line.equals("list")){ |
There was a problem hiding this comment.
Consider using a switch-case statement for neatness
kaseykwok
left a comment
There was a problem hiding this comment.
Nice work. Hope my review could help you well.
| @@ -0,0 +1,33 @@ | |||
| public class Task { | |||
| private String description; | |||
| private boolean marking; | |||
There was a problem hiding this comment.
Consider changing the naming of the boolean variable to "isXXX".
| @@ -0,0 +1,25 @@ | |||
| public class Message { | |||
| public static void printingGreeting() { | |||
There was a problem hiding this comment.
Consider naming the function's name as printGreeting() instead of printingGreeting().
| printingHorizontalLine(); | ||
| } | ||
|
|
||
| public static void printingExit() { |
There was a problem hiding this comment.
May change the function name to printExit()
| printingHorizontalLine(); | ||
| } | ||
|
|
||
| public static void printingHorizontalLine() { |
There was a problem hiding this comment.
May change the function name to printHorizontalLine()
| System.out.println("-----------------------------------------------------------"); | ||
| } | ||
|
|
||
| public static void printingEcho(String line) { |
There was a problem hiding this comment.
May change the function name to printEcho()
| public void addTask(String input) { | ||
| if (input.contains("/by") || input.split(" ")[0].equals("deadline")) { | ||
| if (input.split(" ", 2)[0].equals("deadline")) { | ||
| input = input.split(" ", 2)[1]; |
There was a problem hiding this comment.
Avoid recycling variable. Consider declaring another variable String description to store instead of using input again.
|
|
||
|
|
||
| public List() { | ||
| tasks = new Task[100]; |
There was a problem hiding this comment.
Avoid using magic literals. Consider declaring a constant for it.
| try { | ||
| wordsInput = input.split(space); | ||
| } catch (ArrayIndexOutOfBoundsException e) { | ||
| throw new DukeException(); |
There was a problem hiding this comment.
consider adding a message to the Duke Exception so you can send a direct error message to the user!
| @@ -0,0 +1,35 @@ | |||
| package duke; | |||
| public class Message { | |||
There was a problem hiding this comment.
I really like the fact that you made a Message class! Wish I did this in mine because it would be easier to read many of my methods :)
| public static void echo() { | ||
| String line; | ||
| Scanner in = new Scanner(System.in); | ||
| line = in.nextLine(); |
There was a problem hiding this comment.
maybe consider doing in.nextLine().toLowerCase() so it still works if the user accidentally makes anything uppercase
| } catch (NumberFormatException e) { | ||
| throw new DukeException(); | ||
| } | ||
| if (taskNumber > dukeList.getListSize()) { |
There was a problem hiding this comment.
make you can also put this in the try, since you are throwing an exception as well (might make it easier to read). not necessary at all though
|
|
||
| public void markDone() { | ||
| System.out.println("Nice! I've marked this task as done:"); | ||
| isDone = true; |
There was a problem hiding this comment.
maybe you can make isDone = "X" or a " " since it would slightly shorten your code. Whenever you want to check isDone is true, you can just check if isDone == "X" instead. not necessary for functionality!
sevenseasofbri
left a comment
There was a problem hiding this comment.
Hi Mor Ben Ami, good job on the iP so far! I have added some comments on the code quality, coding standard violations and naming conventions. Hope they will be helpful. 👍🏽
| private static final List dukeList = new List(); | ||
| public static final String markDone = "mark"; | ||
| public static final String bye = "bye"; | ||
| public static final String list = "list"; | ||
| public static final String space = " "; | ||
| public static final String unmarkDone = "unmark"; |
There was a problem hiding this comment.
Please follow the naming convention for final variables. That is, the names should be all-caps.
| public static final String unmarkDone = "unmark"; | ||
|
|
||
| public static void main(String[] args) { | ||
| String logo = " ____ _ \n" |
There was a problem hiding this comment.
Consider refactoring this magic literal to a final variable in the class.
| public static final int arraySize = 100; | ||
| private static int amountOfItems = 0; | ||
| private static duke.task.Task[] tasks; | ||
| public static final String deadline = "deadline"; | ||
| public static final String todo = "todo"; | ||
| public static final String event = "event"; | ||
| public static final String by = " /by "; | ||
| public static final String at = " /at "; | ||
| public static final String space = " "; |
There was a problem hiding this comment.
Consider using the correct naming convention for final variables.
| if (divideByFirstSpace.length < 2 || divideByFirstSpace[1].equals("")){ | ||
| throw new DukeException(); | ||
| } | ||
| switch (divideByFirstSpace[0]) { |
There was a problem hiding this comment.
Perhaps store divideByFirstSpace[0] in a variable and then perform switch-case using it. It will make the code more understandable to the reader.
| public void markItemDone(int i) { | ||
| tasks[i - 1].markDone(); | ||
| } | ||
|
|
||
| public void unmarkItemDone(int i) { | ||
| tasks[i - 1].unmarkDone(); | ||
| } |
There was a problem hiding this comment.
Avoid naming variables that are not counters non-descriptive names like i. Consider naming it itemNum or something along those lines.
| printHorizontalLine(); | ||
| } | ||
|
|
||
| public static void printingExit() { |
There was a problem hiding this comment.
Consider renaming this function to printExit rather than printingExit
# Conflicts: # src/main/java/duke/List.java
added javaDoc
# Conflicts: # src/main/java/duke/TaskList.java # src/main/java/duke/task/Task.java
level 1,2,3