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

[yuhengr] ip #193

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

[yuhengr] ip #193

wants to merge 49 commits into from

Conversation

yuhengr
Copy link

@yuhengr yuhengr commented Feb 9, 2024

No description provided.

Copy link

@webtjs webtjs 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! Overall, the code follows the code quality guidelines. Naming of variables & methods are appropriate, and the code is readable with the exception of some long lines.

int fromPosition = userInput.indexOf("/from");
int toPosition = userInput.indexOf("/to");

tasks[taskCount] = new Event(userInput.substring(dividerPosition + 1, fromPosition - 1), userInput.substring(fromPosition + 6, toPosition - 1), userInput.substring(toPosition + 4));
Copy link

@webtjs webtjs Feb 9, 2024

Choose a reason for hiding this comment

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

Maybe you can consider line wrapping? This line seems quite long.

else if(words[0].equals("deadline")){
int dividerPosition = userInput.indexOf(" ");
int slashPosition = userInput.indexOf("/by");
tasks[taskCount] = new Deadline(userInput.substring(dividerPosition + 1, slashPosition - 1), userInput.substring(slashPosition + 4));
Copy link

@webtjs webtjs Feb 9, 2024

Choose a reason for hiding this comment

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

Maybe you can consider line wrapping for this line also?


String userInput;
Scanner in = new Scanner(System.in);
Task[] tasks = new Task[100];
Copy link

Choose a reason for hiding this comment

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

I like the use of plural form to indicate multiple tasks

@@ -6,5 +8,72 @@ public static void main(String[] args) {
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
Copy link

@webtjs webtjs Feb 9, 2024

Choose a reason for hiding this comment

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

Should the logo variable be deleted since it's not used?

Comment on lines 10 to 20
public String getStatusIcon() {
return (isDone ? "X" : " ");
}

public void markAsDone() {
this.isDone = true;
}

public void markAsNotDone() {
this.isDone = false;
}
Copy link

Choose a reason for hiding this comment

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

Method names are good as they sound like verbs

Copy link

@nichyjt nichyjt left a comment

Choose a reason for hiding this comment

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

Hi Yu Heng,

Try to avoid using magic literals in your program, this is a code quality requirement!
Do consider refactoring some parts of your code that are very long. This will help in readability!

There are some other specific comments below. Try and fix them before the next tutorial!

For your consideration: There is a way to autoformat your code automatically every time you Ctrl-S on intellij which will save you much pain. :)

@@ -0,0 +1,14 @@
public class Deadline extends Task{
Copy link

Choose a reason for hiding this comment

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

Formatting error with the curly brace!

public class Duke {
public static void main(String[] args) {
/*
String logo = " ____ _ \n"
Copy link

Choose a reason for hiding this comment

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

Ditto with the comment by your peer. Remove code that is commented out!

String userInput;
Scanner in = new Scanner(System.in);
ArrayList<Task> tasks = new ArrayList<>();
// Task[] tasks = new Task[100];
Copy link

Choose a reason for hiding this comment

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

Remove unused code, please.

while(!userInput.equals("bye")){
String[] userInputWords = userInput.split(" ");

if(userInput.equals("list")){
Copy link

Choose a reason for hiding this comment

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

This if-else chain is nested and very long. This usually hints that there can be room for improvement for making your code SLAP more.

To aid you in achieving SLAP, here are some guiding questions...

  1. What parts of the code is repetitive? i.e. virtually the same for each if/else block you have
  2. What part of the code does a particular function that can be isolated into a function?

int fromPosition = userInput.indexOf("/from");
int toPosition = userInput.indexOf("/to");

tasks.add(new Event(userInput.substring(dividerPosition + 1, fromPosition - 1), userInput.substring(fromPosition + 6, toPosition - 1), userInput.substring(toPosition + 4)));
Copy link

Choose a reason for hiding this comment

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

This is pretty hard to read, especially with all the magic literals. Do refactor your magic literals. You can consider breaking this up into a function!

@@ -0,0 +1,15 @@
public class Event extends Task{
Copy link

Choose a reason for hiding this comment

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

Formatting error with the curly brace!

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.

3 participants