-
Notifications
You must be signed in to change notification settings - Fork 200
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
[Ong Jun Lin Jeremiah] iP #212
base: master
Are you sure you want to change the base?
Conversation
src/main/java/Duke.java
Outdated
@@ -1,10 +1,73 @@ | |||
public class Duke { | |||
import java.util.Scanner; | |||
import java.util.*; |
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 you could list the imported classes explicitly
src/main/java/Duke.java
Outdated
public class | ||
Duke { |
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.
public class | |
Duke { | |
public class Duke { |
src/main/java/Duke.java
Outdated
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
|
||
String greeting = ("____________________________________________________________\n" | ||
+ "Hello! I'm Duke\n" + "What can I do for you?\n" | ||
+ "____________________________________________________________\n" | ||
); | ||
|
||
String goodBye = ("____________________________________________________________\n" | ||
+ "Bye. Hope to see you again soon!\n" | ||
+ "____________________________________________________________\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.
Perhaps you can change your constant names to be all uppercase using underscore to separate words
src/main/java/Duke.java
Outdated
System.out.println("OK, I've marked this task as not done yet:\n" + " " | ||
+ toDoList.get(itemNumber).getStatusIcon() + toDoList.get(itemNumber).getDescription()); |
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 think you did a good job indenting wrapped lines.
src/main/java/Duke.java
Outdated
String greeting = ("____________________________________________________________\n" | ||
+ "Hello! I'm Duke\n" + "What can I do for you?\n" | ||
+ "____________________________________________________________\n" | ||
); | ||
|
||
String goodBye = ("____________________________________________________________\n" | ||
+ "Bye. Hope to see you again soon!\n" | ||
+ "____________________________________________________________\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.
You may want to refactor the greeting and goodbye into another function instead of putting it all in main(). For example a void printGreeting() function that just prints the greeting
src/main/java/Task.java
Outdated
public class Task { | ||
protected String description; | ||
protected boolean isDone; | ||
protected int taskNumber; |
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.
There are no methods that uses taskNumber?
src/main/java/Duke.java
Outdated
String logo = " ____ _ \n" | ||
+ "| _ \\ _ _| | _____ \n" | ||
+ "| | | | | | | |/ / _ \\\n" | ||
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); |
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.
Can be refactored into print logo function, or you can combine it with the print greeting function
src/main/java/Duke.java
Outdated
ArrayList<Task> toDoList = new ArrayList<Task>(100); | ||
|
||
while (!userInput.equals("bye")) { | ||
if (!containsNumbers(userInput)) { |
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.
You probably don't need this if clause. Instead, you can see if the input string contains "list", "mark", or "unmark", and create 3 separate switch cases for them. Even better, you can refactor this entire if else block into a function that parses the user input.
src/main/java/Duke.java
Outdated
System.out.print(item.getStatusIcon()); | ||
System.out.println(item.getDescription()); | ||
} | ||
System.out.println("____________________________________________________________\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.
You can declare a constant for the row of underscores, or you can just create a function printLine to print the row of underscores. Also, you may want to use System.lineSeparator() instead of '\n' as recommended by the module.
src/main/java/Duke.java
Outdated
System.out.print((toDoList.indexOf(item) + 1) + "."); | ||
System.out.print(item.getStatusIcon()); | ||
System.out.println(item.getDescription()); |
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.
Can be refactored into a separate function printTask(), since all tasks have the same format to be printed. In addition, depending on the situation, you may want to create a new function for each System.out.print() call, if you print the same thing multiple time.
src/main/java/Duke.java
Outdated
public class | ||
Duke { |
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 bring Duke {
in line 5 to the same line as public class
(line 4)
public class | |
Duke { | |
public class Duke { |
src/main/java/Duke.java
Outdated
import java.util.ArrayList; | ||
|
||
public class | ||
Duke { | ||
public static void main(String[] args) { |
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.
Your main method is far too long, the recommendation according to the textbook is 30 LOC. Please try to modularize your main method.
No description provided.