Skip to content
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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open

Conversation

morbenami1
Copy link

level 1,2,3

Copy link

@CheahHaoYi CheahHaoYi left a comment

Choose a reason for hiding this comment

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

Nice



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

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

@@ -0,0 +1,33 @@
public class Task {
private String description;
private boolean marking;

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"

marking = false;
}

public void markDone() {

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

line = in.nextLine();
while (!line.equals("bye")){
words = line.split(" ");
if (line.equals("list")){

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

Copy link

@kaseykwok kaseykwok left a 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.

@@ -0,0 +1,33 @@
public class Task {
private String description;
private boolean marking;

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

@@ -0,0 +1,25 @@
public class Message {
public static void printingGreeting() {

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

printingHorizontalLine();
}

public static void printingExit() {

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

printingHorizontalLine();
}

public static void printingHorizontalLine() {

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

System.out.println("-----------------------------------------------------------");
}

public static void printingEcho(String line) {

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

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

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.



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

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.

try {
wordsInput = input.split(space);
} catch (ArrayIndexOutOfBoundsException e) {
throw new DukeException();
Copy link

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!

@@ -0,0 +1,35 @@
package duke;
public class Message {
Copy link

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

public static void echo() {
String line;
Scanner in = new Scanner(System.in);
line = in.nextLine();
Copy link

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

} catch (NumberFormatException e) {
throw new DukeException();
}
if (taskNumber > dukeList.getListSize()) {
Copy link

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


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

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!

Copy link

@sevenseasofbri sevenseasofbri left a 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. 👍🏽

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

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.

public static final String unmarkDone = "unmark";

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

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 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 = " ";

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.

if (divideByFirstSpace.length < 2 || divideByFirstSpace[1].equals("")){
throw new DukeException();
}
switch (divideByFirstSpace[0]) {

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 on lines 40 to 46
public void markItemDone(int i) {
tasks[i - 1].markDone();
}

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

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

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