Skip to content

[Ege Demirkirkan] iP#71

Open
edemirkirkan wants to merge 34 commits into
nus-cs2113-AY2122S2:masterfrom
edemirkirkan:master
Open

[Ege Demirkirkan] iP#71
edemirkirkan wants to merge 34 commits into
nus-cs2113-AY2122S2:masterfrom
edemirkirkan:master

Conversation

@edemirkirkan

Copy link
Copy Markdown

No description provided.

@FTang21 FTang21 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall good job on following the coding standard

Comment thread src/main/java/InputParser.java Outdated
@@ -0,0 +1,83 @@
public class InputParser {
protected String[] args;
protected static String[] validCommands = {"mark", "m", "unmark", "um", "todo", "t", "deadline", "d", "event", "e", "list", "ls", "bye", "exit", "quit", "q"};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I believe this is over 120 characters, perhaps make this into two separate lines?

Comment thread src/main/java/JRobo.java Outdated
continue;
}
String command = parser.getPrefix();
switch (command) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Well done on the switch statement formatting!

@suenalaba suenalaba left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean code with little violation.

Comment on lines +3 to +5
public class TaskManager {
ArrayList<Task> tasks;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good: Plural form used to represent a collection of tasks. This is a common error that you avoided!

Comment thread src/main/java/InputParser.java Outdated
@@ -0,0 +1,83 @@
public class InputParser {
protected String[] args;
protected static String[] validCommands = {"mark", "m", "unmark", "um", "todo", "t", "deadline", "d", "event", "e", "list", "ls", "bye", "exit", "quit", "q"};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should use line wrapping instead, try to keep to a maximum of 120 characters per line.
Take note indentation for wrapped lines should be 8 spaces.

Comment thread src/main/java/JRobo.java Outdated
Comment on lines +23 to +44
switch (command) {
case "mark":
case "m":
manager.markTask(parser.getBody());
break;
case "unmark":
case "um":
manager.unmarkTask(parser.getBody());
break;
case "list":
case "ls":
manager.displayTaskList();
break;
case "bye":
case "b":
case "quit":
case "q":
break label;
default:
manager.addTask(parser.getBody(), parser.getSuffix(), parser.getType());
break;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good: You indented the case statement correctly, this is a common mistake which you avoid.

Comment on lines +48 to +49
printWithSeparator("Nice! I've marked this task as done:", "\t[" + task.getStatusIcon() + "] "
+ task.getDescription());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of line wrapping here so that code is kept within 120 characters per line.
Correct indentation of wrapped line too at 8 spaces.

@xseh xseh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good attempt! Do take note of magic literals and some variable naming (especially when it comes to loops).

Comment thread src/main/java/JRobo.java Outdated
public static void run(Scanner scanner, TaskManager manager) {
manager.welcomeUser();
label:
while (true) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid magic booleans. Consider putting into variable (e.g. canContinue)

Comment thread src/main/java/JRobo.java Outdated
Comment on lines +46 to +47
manager.addTask(parser.getBody(), parser.getSuffix(), parser.getType());
} catch (jrobo.exception.InvalidFormatException | jrobo.exception.InvalidTypeException e) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid complicated expressions. Consider refactoring the line into separator methods.

}

public String getPrefix() {
for (String s : validCommands) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider renaming the variable s in improve readability, such as command


public String getSuffix() {
int suffixIndex = findSuffixIndex();
if (suffixIndex == -1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid magic numbers. Consider declaring a variable (e.g. INVALID_INDEX) for the integer -1 instead.

Comment on lines +64 to +73
if (!isDeadline && !isEvent && (getPrefix().equals("todo") || getPrefix().equals("t"))) {
return "todo";
}
if (isDeadline && (getPrefix().equals("deadline") || getPrefix().equals("d"))) {
return "deadline";
}
if (isEvent && (getPrefix().equals("event") || getPrefix().equals("e"))) {
return "event";
}
throw new InvalidFormatException("Invalid command format!");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider SLAPing more by refactoring the code into separate methods.

int found = -1;
for (int i = 0; i < args.length; i++) {
String s = args[i];
if (s.equals("/at") || s.equals("/by")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Avoid magic literals. Consider putting strings "/at" and "/by" into variables (e.g. COMMAND_AT and COMMAND_BY)

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