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

[Nguyen D.Q. Minh] iP #450

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

Conversation

nguyendqminh
Copy link

No description provided.

Copy link

@afroneth afroneth left a comment

Choose a reason for hiding this comment

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

Good job! The overall code quality is high. However, there is a need to refactor some small code style violations.

public String toString() {
return String.format("[D]%s (by: %s)", super.toString(), this.by);
}
}

Choose a reason for hiding this comment

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

I like the clean code here. Is it perhaps better to rename the variable "by" to something clearer?

}

public static void main(String[] args) throws Exception {
new Duke().execute();

Choose a reason for hiding this comment

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

Good usage of OOP principles!

Parser parser = new Parser(command);
String commandType = parser.getCommandType();
switch (commandType) {
case "bye": {

Choose a reason for hiding this comment

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

Shouldn't there be no indentation for case clauses?

private String commandType;
private int index;

public Parser(String command) {

Choose a reason for hiding this comment

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

Is there too much usage of if-else loops here?

BufferedWriter writer = Files.newBufferedWriter(this.filePath);
writer.write(String.valueOf(tasks.size()));
writer.newLine();
for(Task task : tasks) {

Choose a reason for hiding this comment

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

Should there be a white space character after 'for'?

openFile();
BufferedReader reader = Files.newBufferedReader(this.filePath);
int taskCount = Integer.parseInt(reader.readLine());
for(int i = 0; i < taskCount; ++i) {

Choose a reason for hiding this comment

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

Should there be a white space character after 'for'?

boolean isDone = (status.equals("[O]"));
Task result;

switch (taskType) {

Choose a reason for hiding this comment

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

Shouldn't there be no indentation for case clauses?

throw new DukeException("Error while loading data.");
}
}

Choose a reason for hiding this comment

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

Is line 35 (blank statement) removable?

Copy link

@Asuraxsoul Asuraxsoul left a comment

Choose a reason for hiding this comment

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

In general, I feel that your code mostly complies to the coding standards specified, and I feel that there are only a few minor tweaks here and there required.

Good job for designing your duke program in a way that it is very easy to read and understand! 👍

@@ -0,0 +1,18 @@
public class Deadline extends Task {
protected String by;

Choose a reason for hiding this comment

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

Maybe you can change "by" variable name to be more descriptive? Can consider "timeDescription"?

@@ -0,0 +1,18 @@
public class Event extends Task {
protected String at;

Choose a reason for hiding this comment

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

Similar to Deadline class, could the "at" variable name be changed to something more descriptive?

throw new DukeException(":( OOPS!!! The description of an event cannot be empty.");
}
String rest = command.substring(6);
int at_position = rest.indexOf("/at ");

Choose a reason for hiding this comment

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

Should underscore be used for naming here? According to the coding standards, underscores may be used in test method names and for constant names that are all caps (eg, MAX_ITERATIONS).

}

private String getStatusIcon() {
return isDone ? "O" : "X";

Choose a reason for hiding this comment

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

Consider storing "O" and "X" as constants and then referring to them?

public String toString() {
return String.format("[%s] %s", this.getStatusIcon(), this.description);
}
}

Choose a reason for hiding this comment

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

I feel that it would be better to add 1 empty line at the end of this file so that git knows that the file terminates here.

System.out.println(e.getMessage());
}

public void greetings() {

Choose a reason for hiding this comment

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

Can consider changing "greetings" method name to a verb form such as "greet".

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