-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Shi Haochen] iP #77
base: master
Are you sure you want to change the base?
[Shi Haochen] iP #77
Conversation
src/main/java/Duke.java
Outdated
String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; | ||
String line = "_______________________________________________"; | ||
String exit = "Bye. Hope to see you again soon!"; | ||
String listRequirements = "Here are the tasks in your 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.
Good job! Use of camelCase
src/main/java/Duke.java
Outdated
+ "| |_| | |_| | < __/\n" | ||
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; |
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 use capital letters for constant eg. GREET
src/main/java/Duke.java
Outdated
List<Task> todoList = new ArrayList<>(); | ||
while(true){ | ||
String input = scanner.nextLine(); | ||
if(input.equals("bye")){ |
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.
Remember to add spacing for if else class statements eg. if (something) {
src/main/java/Duke.java
Outdated
@@ -1,10 +1,56 @@ | |||
import java.util.Scanner; | |||
import java.util.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.
Good job! names representing packages are in lower case
@@ -0,0 +1,25 @@ | |||
public class Task { |
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.
Good job use of PascalCase for classes
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.
Overall, I found your code easy to read for the most part except main class appears to be a bit packed. Perhaps we can add some blank lines to improve readability. And perhaps encapsulate some of its functionalities if that make sense!
src/main/java/Duke.java
Outdated
todoList.get(index-1).markAsDone(); | ||
System.out.println(line); | ||
System.out.println(markRequirements); | ||
System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).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.
Perhaps spilt the code into 2 lines evenly? first line looks a bit to long for me. I noticed the same issue in several other places too.
src/main/java/Duke.java
Outdated
String markFormat = "^mark \\d+$"; | ||
String unmarkFormat = "^unmark \\d+$"; |
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 have some confusion regarding these strings. Can you provide some clarification on their meaning?
src/main/java/Duke.java
Outdated
while(true){ | ||
String input = scanner.nextLine(); | ||
if(input.equals("bye")){ | ||
break; | ||
}else if(input.equals("list")){ | ||
System.out.println(line); | ||
System.out.println(listRequirements); | ||
for(int i = 0; i < todoList.size(); i++){ | ||
System.out.println(i+1 + ".[" + todoList.get(i).getStatusIcon() + "] " + todoList.get(i).getDescription()); | ||
} | ||
System.out.println(line); | ||
}else if(input.matches(markFormat)) { | ||
int index = Integer.parseInt(input.substring(5)); | ||
todoList.get(index-1).markAsDone(); | ||
System.out.println(line); | ||
System.out.println(markRequirements); | ||
System.out.println(" [" + todoList.get(index-1).getStatusIcon() + "] " + todoList.get(index-1).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.
Perhaps encapsulate some of its functionalities into separate methods so that this while loop can be more concise.
src/main/java/Duke.java
Outdated
System.out.println("Hello from\n" + logo); | ||
String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; | ||
String line = "_______________________________________________"; | ||
String exit = "Bye. Hope to see you again soon!"; |
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.
Since this line is used only once, should it be extracted out and just print it directly when needed?
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.
Generally good adherence to coding standards. Some variable names can be improved to be more informative.
Good use of execeptions
src/main/java/Duke.java
Outdated
public class Duke { | ||
protected final static 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.
follow the correct naming standard for constants
src/main/java/Duke.java
Outdated
+ "|____/ \\__,_|_|\\_\\___|\n"; | ||
System.out.println("Hello from\n" + logo); | ||
String greet = "Hello! I'm Elwin\n" + "What can I do for you?"; | ||
//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.
remove unecessary code
Shi Haochen's individual project update.