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

[Chuyue] iP #349

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

[Chuyue] iP #349

wants to merge 41 commits into from

Conversation

ramenmen
Copy link

No description provided.

Copy link

@lamlaaaam lamlaaaam left a comment

Choose a reason for hiding this comment

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

Might want to review the longer methods and try to split up responsibilities more.

@@ -0,0 +1,10 @@
public enum Command {
blank,

Choose a reason for hiding this comment

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

Perhaps change the constants to all caps? e.g. BLANK, CLEAR, etc.

this.deadline = deadline;
}
public String toString() {
String donez;

Choose a reason for hiding this comment

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

Might want to change the variable name to something clearer?

}
public String toString() {
String donez;
if (done) {

Choose a reason for hiding this comment

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

"done" seems like a boolean value, maybe try "isDone"?

Copy link

Choose a reason for hiding this comment

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

boolean method can be named isDone() instead.

/**
* Contains most of the chat bot logic
*/
public void run() {

Choose a reason for hiding this comment

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

Perhaps extract out certain parts into helper methods? Currently this method seems too long and will only grow longer as more logic is added.

} else {
task = tasks.get(current);
tasks.delete(current);
Ui.print("i've removed the following task from the list:\n\t" + task + "\nnow you have " + tasks.size() + " items in your tasklist.");

Choose a reason for hiding this comment

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

Maybe split up this line as it is too long?

* @param in The string to be parsed.
* @return The task required by the input string.
*/
public static Task getTask(String in) {

Choose a reason for hiding this comment

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

Again, maybe consider breaking the method up into several smaller ones?

List<Task> result = new ArrayList<Task>();
File myObj = new File(filePath);
Scanner myReader;
try {

Choose a reason for hiding this comment

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

This code block is getting close to an arrowhead style! Maybe try to refrain nesting too many try blocks?

if (taskType.equals("T")) {
tempTask = new ToDo(result[2]);
} else if (taskType.equals("D")) {
tempTask = new Deadline(result[2],LocalDateTime.parse(result[3],DateTimeFormatter.ofPattern("dd MMM yyyy HHmm")));

Choose a reason for hiding this comment

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

Parameters look quite long and there's many magic numbers, maybe split up the lines and use constants?

* Prints an error message with the associated formatting.
* @param msg The message to be printed.
*/
public static void errorMsg(String msg) {

Choose a reason for hiding this comment

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

Perhaps change the method name to "printErrorMsg"?

Copy link

Choose a reason for hiding this comment

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

Perhaps change the method name to "printErrorMessage" or "printErrorMsg" as mentioned by Zhi Yuan.

@Test
public void parserTestReturnError(){
assertEquals(Parser.parse("dfgjdhg"), Command.error);
assertEquals(Parser.parse("todo"), Command.error);

Choose a reason for hiding this comment

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

Why does parsing "todo" and "event" expect an error command?

Copy link

@marcustw marcustw left a comment

Choose a reason for hiding this comment

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

Great job! Java OOP adhered!

@@ -0,0 +1,10 @@
public enum Command {
blank,
clear,
Copy link

Choose a reason for hiding this comment

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

Should it these enum constants be in all caps?

}
public String toString() {
String donez;
if (done) {
Copy link

Choose a reason for hiding this comment

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

boolean method can be named isDone() instead.

+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
new Duke("duke.txt").run();
Copy link

Choose a reason for hiding this comment

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

Very clean psvm method!


public class Event extends Task {
private LocalDateTime startDate;
public Event(String in, LocalDateTime start) {
Copy link

Choose a reason for hiding this comment

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

Perhaps a line space between properties and the class constructor.


public class Deadline extends Task {
private LocalDateTime deadline;
public Deadline(String in, LocalDateTime deadline) {
Copy link

Choose a reason for hiding this comment

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

Perhaps a line space between properties and class constructor.

public class Parser {
/**
* Converts the string to a type of command.
* @param in The string to be parsed.
Copy link

Choose a reason for hiding this comment

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

Perhaps add a space between Javadoc description and @param (line 6 and 7).

import java.time.format.DateTimeFormatter;

public class Task {
protected boolean done;
Copy link

Choose a reason for hiding this comment

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

Perhaps boolean can be named "isDone"?

}

/**
* Converts tasks in taskList to String format.
Copy link

Choose a reason for hiding this comment

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

Perhaps you can leave a line space between line 43 and line 44

* Prints an error message with the associated formatting.
* @param msg The message to be printed.
*/
public static void errorMsg(String msg) {
Copy link

Choose a reason for hiding this comment

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

Perhaps change the method name to "printErrorMessage" or "printErrorMsg" as mentioned by Zhi Yuan.

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.

None yet

3 participants