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

[Hao Yun]iP #53

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

[Hao Yun]iP #53

wants to merge 42 commits into from

Conversation

HAOYUN49
Copy link

No description provided.

j-lum and others added 12 commits August 6, 2019 15:25
Add toolVersion block in to Gradle code sample to prevent errors.
Gradle defaults to an empty stdin which results in runtime exceptions
when attempting to read from `System.in`. Let's add some sensible
defaults for students who may still need to work with the standard
input stream.
Add configuration for console applications
The OpenJFX plugin expects applications to be modular and bundled
with jlink, resulting in fat jars that are not cross-platform. Let's
manually include the required dependencies so that shadow can package
them properly.
Copy link

@alexlim510 alexlim510 left a comment

Choose a reason for hiding this comment

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

Generally, your code is easy to read for the most part. Perhaps you can be more careful with the naming of the methods to prevent confusion. We hope that our comments can help you to enhance your code further.
All the best for your iP :D
[Also took part in this review: @kcubey]

src/main/java/Duke.java Outdated Show resolved Hide resolved
System.out.println("------------------------------------");
System.out.println();
}

public static void main(String[] args) {
String logo = " ____ _ \n"

Choose a reason for hiding this comment

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

Perhaps you may want to consider putting the logo and the print statements into another method to better implement the SLAP principle such as the greet() method.

System.out.println("------------------------------------");
System.out.println("Here is the list of all tasks you have:");
for(int i = 0; i < numOfTasks; i++) {
System.out.println(String.format("%d.[%c] %s", i+1,(tasks[i].isDone? '✓':'✗'), tasks[i].name));

Choose a reason for hiding this comment

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

You may want to consider seperating this statement into a few more lines to make the code more readable. For example, you may want to first create variables for each item in the print function:
String isDone = tasks[i].isDone? '✓':'✗';

} else if (command.equals("list")){
manager.listTask();
} else if (command.startsWith("done")){
manager.markTask(Integer.parseInt(command.substring(5)));

Choose a reason for hiding this comment

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

You may want to consider creating a constant for the number 5 here. Creating a constant can help to give more meaning to the number written here.

Reference Link: Magic Number

Alternatively, you may want to consider changing this line to be more descriptive to avoid confusion, such as
int taskNum = Integer.parseInt(command.substring(5)), or adding a comment to make it clearer what this does, like //command syntax: done 6


private TaskManager manager = new TaskManager();

public void exit() {

Choose a reason for hiding this comment

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

You may want to consider changing the name of this method to make it more descriptive, as it could be confused for System.exit()

System.out.println();
}

public void run() {

Choose a reason for hiding this comment

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

Similarly, you could consider renaming this method to be more descriptive, as it could be confused for the Java Thread run() method

public void markTask(int taskNo) {
System.out.println("------------------------------------");
System.out.println("Good job! You have done this task:");
System.out.println(" [✓] " + tasks[taskNo-1].name);

Choose a reason for hiding this comment

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

You may want to consider changing this whitespace to \t, to standardise any future tabbed spaces and to reduce confusion for future implementation by other viewers

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