-
Notifications
You must be signed in to change notification settings - Fork 77
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
Mor Ben Ami #66
base: master
Are you sure you want to change the base?
Mor Ben Ami #66
Conversation
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.
Nice
src/main/java/List.java
Outdated
|
||
|
||
public List() { | ||
tasks = new Task[100]; |
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.
The use of magic number here is ambiguous, feel free to consider using a constant
src/main/java/Task.java
Outdated
@@ -0,0 +1,33 @@ | |||
public class Task { | |||
private String description; | |||
private boolean marking; |
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.
boolean values should be named to sound like booleans, consider "isMarked" or "isFinished"
src/main/java/Task.java
Outdated
marking = false; | ||
} | ||
|
||
public void markDone() { |
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.
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
src/main/java/Duke.java
Outdated
line = in.nextLine(); | ||
while (!line.equals("bye")){ | ||
words = line.split(" "); | ||
if (line.equals("list")){ |
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.
Consider using a switch-case statement for neatness
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.
Nice work. Hope my review could help you well.
src/main/java/Task.java
Outdated
@@ -0,0 +1,33 @@ | |||
public class Task { | |||
private String description; | |||
private boolean marking; |
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.
Consider changing the naming of the boolean variable to "isXXX".
src/main/java/Message.java
Outdated
@@ -0,0 +1,25 @@ | |||
public class Message { | |||
public static void printingGreeting() { |
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.
Consider naming the function's name as printGreeting()
instead of printingGreeting()
.
src/main/java/Message.java
Outdated
printingHorizontalLine(); | ||
} | ||
|
||
public static void printingExit() { |
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.
May change the function name to printExit()
src/main/java/Message.java
Outdated
printingHorizontalLine(); | ||
} | ||
|
||
public static void printingHorizontalLine() { |
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.
May change the function name to printHorizontalLine()
src/main/java/Message.java
Outdated
System.out.println("-----------------------------------------------------------"); | ||
} | ||
|
||
public static void printingEcho(String line) { |
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.
May change the function name to printEcho()
src/main/java/List.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid recycling variable. Consider declaring another variable String description
to store instead of using input
again.
src/main/java/List.java
Outdated
|
||
|
||
public List() { | ||
tasks = new Task[100]; |
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.
Avoid using magic literals. Consider declaring a constant for it.
src/main/java/duke/Duke.java
Outdated
try { | ||
wordsInput = input.split(space); | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
throw new DukeException(); |
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.
consider adding a message to the Duke Exception so you can send a direct error message to the user!
src/main/java/duke/Message.java
Outdated
@@ -0,0 +1,35 @@ | |||
package duke; | |||
public class Message { |
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 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 :)
src/main/java/duke/Duke.java
Outdated
public static void echo() { | ||
String line; | ||
Scanner in = new Scanner(System.in); | ||
line = in.nextLine(); |
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.
maybe consider doing in.nextLine().toLowerCase() so it still works if the user accidentally makes anything uppercase
src/main/java/duke/Duke.java
Outdated
} catch (NumberFormatException e) { | ||
throw new DukeException(); | ||
} | ||
if (taskNumber > dukeList.getListSize()) { |
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.
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
src/main/java/duke/task/Task.java
Outdated
|
||
public void markDone() { | ||
System.out.println("Nice! I've marked this task as done:"); | ||
isDone = true; |
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.
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!
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.
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. 👍🏽
src/main/java/duke/Duke.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the naming convention for final
variables. That is, the names should be all-caps.
src/main/java/duke/Duke.java
Outdated
public static final String unmarkDone = "unmark"; | ||
|
||
public static void main(String[] args) { | ||
String logo = " ____ _ \n" |
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.
Consider refactoring this magic literal to a final variable in the class.
src/main/java/duke/List.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the correct naming convention for final
variables.
src/main/java/duke/List.java
Outdated
if (divideByFirstSpace.length < 2 || divideByFirstSpace[1].equals("")){ | ||
throw new DukeException(); | ||
} | ||
switch (divideByFirstSpace[0]) { |
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.
Perhaps store divideByFirstSpace[0]
in a variable and then perform switch-case using it. It will make the code more understandable to the reader.
src/main/java/duke/List.java
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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