Skip to content

Mor Ben Ami#66

Open
morbenami1 wants to merge 27 commits into
nus-cs2113-AY2223S1:masterfrom
morbenami1:master
Open

Mor Ben Ami#66
morbenami1 wants to merge 27 commits into
nus-cs2113-AY2223S1:masterfrom
morbenami1:master

Conversation

@morbenami1

Copy link
Copy Markdown

level 1,2,3

@CheahHaoYi CheahHaoYi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice

Comment thread src/main/java/List.java Outdated


public List() {
tasks = new Task[100];

Copy link
Copy Markdown

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

Comment thread src/main/java/Task.java Outdated
@@ -0,0 +1,33 @@
public class Task {
private String description;
private boolean marking;

Copy link
Copy Markdown

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"

Comment thread src/main/java/Task.java Outdated
marking = false;
}

public void markDone() {

Copy link
Copy Markdown

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

Comment thread src/main/java/Duke.java Outdated
line = in.nextLine();
while (!line.equals("bye")){
words = line.split(" ");
if (line.equals("list")){

Copy link
Copy Markdown

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

@kaseykwok kaseykwok left a comment

Copy link
Copy Markdown

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.

Comment thread src/main/java/Task.java Outdated
@@ -0,0 +1,33 @@
public class Task {
private String description;
private boolean marking;

Copy link
Copy Markdown

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".

Comment thread src/main/java/Message.java Outdated
@@ -0,0 +1,25 @@
public class Message {
public static void printingGreeting() {

Copy link
Copy Markdown

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().

Comment thread src/main/java/Message.java Outdated
printingHorizontalLine();
}

public static void printingExit() {

Copy link
Copy Markdown

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()

Comment thread src/main/java/Message.java Outdated
printingHorizontalLine();
}

public static void printingHorizontalLine() {

Copy link
Copy Markdown

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()

Comment thread src/main/java/Message.java Outdated
System.out.println("-----------------------------------------------------------");
}

public static void printingEcho(String line) {

Copy link
Copy Markdown

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()

Comment thread 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];

Copy link
Copy Markdown

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.

Comment thread src/main/java/List.java Outdated


public List() {
tasks = new Task[100];

Copy link
Copy Markdown

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.

Comment thread src/main/java/duke/Duke.java Outdated
try {
wordsInput = input.split(space);
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException();

Copy link
Copy Markdown

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!

Comment thread src/main/java/duke/Message.java Outdated
@@ -0,0 +1,35 @@
package duke;
public class Message {

Copy link
Copy Markdown

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 :)

Comment thread src/main/java/duke/Duke.java Outdated
public static void echo() {
String line;
Scanner in = new Scanner(System.in);
line = in.nextLine();

Copy link
Copy Markdown

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

Comment thread src/main/java/duke/Duke.java Outdated
} catch (NumberFormatException e) {
throw new DukeException();
}
if (taskNumber > dukeList.getListSize()) {

Copy link
Copy Markdown

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

Comment thread src/main/java/duke/task/Task.java Outdated

public void markDone() {
System.out.println("Nice! I've marked this task as done:");
isDone = true;

Copy link
Copy Markdown

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!

@sevenseasofbri sevenseasofbri left a comment

Copy link
Copy Markdown

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. 👍🏽

Comment thread src/main/java/duke/Duke.java Outdated
Comment on lines +6 to +11
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";

Copy link
Copy Markdown

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.

Comment thread src/main/java/duke/Duke.java Outdated
public static final String unmarkDone = "unmark";

public static void main(String[] args) {
String logo = " ____ _ \n"

Copy link
Copy Markdown

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.

Comment thread src/main/java/duke/List.java Outdated
Comment on lines +3 to +11
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 = " ";

Copy link
Copy Markdown

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.

Comment thread src/main/java/duke/List.java Outdated
if (divideByFirstSpace.length < 2 || divideByFirstSpace[1].equals("")){
throw new DukeException();
}
switch (divideByFirstSpace[0]) {

Copy link
Copy Markdown

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.

Comment thread src/main/java/duke/List.java Outdated
Comment on lines +40 to +46
public void markItemDone(int i) {
tasks[i - 1].markDone();
}

public void unmarkItemDone(int i) {
tasks[i - 1].unmarkDone();
}

Copy link
Copy Markdown

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() {

Copy link
Copy Markdown

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

morbenami1 and others added 5 commits September 30, 2022 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants