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

[Shi Haochen] iP #77

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

[Shi Haochen] iP #77

wants to merge 8 commits into from

Conversation

hshiah
Copy link

@hshiah hshiah commented Sep 5, 2023

Shi Haochen's individual project update.

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

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

+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String greet = "Hello! I'm Elwin\n" + "What can I do for you?";

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

List<Task> todoList = new ArrayList<>();
while(true){
String input = scanner.nextLine();
if(input.equals("bye")){

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

@@ -1,10 +1,56 @@
import java.util.Scanner;
import java.util.List;

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 {

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

Copy link

@vvhuiling vvhuiling left a 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!

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

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.

Comment on lines 12 to 13
String markFormat = "^mark \\d+$";
String unmarkFormat = "^unmark \\d+$";

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?

Comment on lines 19 to 35
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());

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.

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

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?

Copy link

@maanyos maanyos left a 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

public class Duke {
protected final static String line = "_______________________________________________";
Copy link

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

+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
String greet = "Hello! I'm Elwin\n" + "What can I do for you?";
//String line = "_______________________________________________";
Copy link

Choose a reason for hiding this comment

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

remove unecessary code

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.

4 participants