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

[shawnpong] iP #178

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

Conversation

shawnpong
Copy link

No description provided.

damithc and others added 11 commits January 7, 2024 18:33
Copy link

@Joshuahoky Joshuahoky left a comment

Choose a reason for hiding this comment

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

Consider refactoring main in Floda.java into different methods to make the code easier to read and understand. Otherwise, code follows Java coding standard well and is of high quality

this.by = by;
}

@Override

Choose a reason for hiding this comment

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

Great use of Override annotation to signal method overriding

} else {
System.out.println("Invalid task number! Please check with 'list'.");
}
} else {

Choose a reason for hiding this comment

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

Avoid arrowhead style code

src/main/java/Floda.java Show resolved Hide resolved

public class Floda {
public static void main(String[] args) {
String name = "Floda";

Choose a reason for hiding this comment

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

Redundant code as it can be combined with the next line
eg. System.out.println("Hello! I'm Floda");

Copy link

@lordgareth10 lordgareth10 left a comment

Choose a reason for hiding this comment

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

Looks okay to me, the coding standards were mostly adhered to in general, however some parts which I commented on could be refactored to improve logical flow and readability.

Choose a reason for hiding this comment

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

Could consider refactoring to use separate methods to handle individual command types. For example, if the command is "event" you could use a handleEventInput() method to parse the string and add the object to the list. This will improve readability considerably.

@@ -0,0 +1,83 @@
import java.util.Scanner;

Choose a reason for hiding this comment

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

I like how you specified java.util.Scanner instead of java.util.* , this complies with coding standards, well done !


public class Floda {
public static void main(String[] args) {
String name = "Floda";

Choose a reason for hiding this comment

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

Should this be a constant? And if it was then perhaps you could have used (public static final string) and capitalised the variable name (NAME) to follow the coding standards.

Comment on lines 12 to 27
while (!"bye".equals((line = scanner.nextLine()))) {
if ("list".equals(line)) {
System.out.println("List so far: ");
for (int i = 0; i < taskCounter; i++) {
System.out.println((i + 1) + "." + list[i]);
}
} else if (line.startsWith("mark")) {
Scanner taskScanner = new Scanner(line);
taskScanner.next();
if (taskScanner.hasNextInt()) {
int taskNumber = taskScanner.nextInt() - 1;
if (taskNumber >= 0 && taskNumber < taskCounter) {
list[taskNumber].setDone(true);
System.out.println("I have marked this task as done:\n" + list[taskNumber]);
} else {
System.out.println("Invalid task number! Please check with 'list'.");

Choose a reason for hiding this comment

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

Perhaps you could refactor the code into smaller methods that handle the logic without having to have so many levels of nesting, this would make the code more readable.

this.description = description;
}

public boolean isDone() {

Choose a reason for hiding this comment

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

I like how the boolean method isDone is namd to sound like a boolean!

Comment on lines 11 to 12
System.out.println("I can keep track of a to-do list for you! Just type what you want to add to the list.");
while (!"bye".equals((line = scanner.nextLine()))) {

Choose a reason for hiding this comment

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

It would improve readability if you directly assigned String line = scanner.nextLine() in the previous line instead of assigning it inside the conditional for the while loop. Then you could read in a new line of input at the end of every if else block.

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 Shawn,

Your code is generally well structured. Good job!

There are some repeated mistakes in the codebase (such as magic literals), so do take note.

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

Comment on lines 11 to 12
private final static String NAME = "Floda";
private static final String FILE_PATH = "./data/tasks.txt";
Copy link

Choose a reason for hiding this comment

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

I'm not sure why the NAME constant left out the static keyword?

src/main/java/Floda.java Outdated Show resolved Hide resolved
src/main/java/Floda.java Outdated Show resolved Hide resolved
src/main/java/Floda.java Outdated Show resolved Hide resolved
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