Skip to content

[Cheah Hao Yi] iP#57

Open
CheahHaoYi wants to merge 42 commits into
nus-cs2113-AY2223S1:masterfrom
CheahHaoYi:master
Open

[Cheah Hao Yi] iP#57
CheahHaoYi wants to merge 42 commits into
nus-cs2113-AY2223S1:masterfrom
CheahHaoYi:master

Conversation

@CheahHaoYi

Copy link
Copy Markdown

Added week 3 iP progress

@dhanish265 dhanish265 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, I think it's quite good. Just need those minor edits that I suggested.

Comment thread src/main/java/Duke.java Outdated
public class Duke {
public static void main(String[] args) {

public static Task[] tasks = new Task[100];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please replace magic literal ('100'). Consider using a final value.

Comment thread src/main/java/Duke.java Outdated
public static Task[] tasks = new Task[100];
public static int numTasks = 0;

public static void listTasks(){

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 think there should be a space between the closing bracket and open brace. You can use the reformat code option for the IDE to do it for you

Comment thread src/main/java/Duke.java Outdated
System.out.println("What can I do for you?");
}

public static boolean toExit(String userInput) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can consider changing the method name to reflect the boolean nature of the method (toExit does not sound like it's a boolean method)

Comment thread src/main/java/Duke.java Outdated
System.out.println("Beep boop, now you have " + numTasks + " tasks");
}

public static void addDeadline(String param){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

perhaps it is accidental, but there are actually 2 spaces between 'public' and 'static' in this method and the next method

@kaseykwok kaseykwok 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.

Nice work. Hope my review could help.

Comment thread src/main/java/Duke.java Outdated
public class Duke {
public static void main(String[] args) {

public static Task[] tasks = new Task[100];

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 using magic literals. Consider adding a constant for it.

Comment thread src/main/java/Duke.java Outdated
final String ERROR_OUT_OF_BOUND = "Sorry, the task does not seem to exist :<";
tasks[whichTask].setStatus(done);

if(whichTask > numTasks){

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 adding spaces before the opening parenthesis and after the closing parenthesis.

Comment thread src/main/java/Duke.java Outdated
System.out.println("Beep boop, now you have " + numTasks + " tasks");
}

public static void addDeadline(String param){

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 double spacing.

Comment thread src/main/java/Duke.java Outdated
*/

final String LOGO = "\n" +
" _________________________________________\n" +

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indentation for wrapped lines should be 8 spaces.

Comment thread src/main/java/Duke.java Outdated

public static void listTasks(){
System.out.println("Beep beep, listing out the tasks....Loading.....");
for(int i = 0; i < numTasks; i++){

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 adding space before the opening parenthesis.

@morbenami1 morbenami1 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.

Over all great job, amazing code and very creative :)

Comment thread src/main/java/Duke.java Outdated
public class Duke {
public static void main(String[] args) {

public static Task[] tasks = new Task[100];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use magic number

Comment thread src/main/java/Duke.java Outdated
}

public static void processUserInput(String userInput){
String[] splitInput = userInput.split(" ", 2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

instead of splitInput- inputSplitedBySpace

Comment thread src/main/java/Task.java Outdated
private boolean isDone;
private String taskDescription;

private final String STATUS_DONE_ICON = "X";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

gread job! adding the final String for the mark status

Comment thread src/main/java/Duke.java Outdated
public static void main(String[] args) {

public static Task[] tasks = new Task[100];
public static int numTasks = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change to a more informative name

@sevenseasofbri sevenseasofbri 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.

Hi Hao Yi, good job on the iP so far! I have added some comments on the code quality, coding standard violations and naming conventions. Hope they will be helpful. 👍🏽

Comment thread src/main/java/Duke/Duke.java Outdated

public static void greetUser() {

final String LOGO = "\n"

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 moving the final variable to make it a global variable in this class.

Comment thread src/main/java/Duke/Duke.java Outdated
Comment on lines +57 to +59
System.out.println(LOGO);
System.out.println("Hello! I'm Duke");
System.out.println("What can I do for you?");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps can avoid the usage of magic literals by declaring these as final variables in this class. (Same for line 64)

Comment thread src/main/java/Duke/Duke.java Outdated
System.out.println("What can I do for you?");
}

public static boolean isToExit(String userInput) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps name this function isExit since it would be easier to understand at first glance.

Comment thread src/main/java/Duke/InputParser.java Outdated
Comment on lines +20 to +24
case ("list"): //Fallthrough
case ("mark"): //Fallthrough
case ("unmark"): //Fallthrough
case ("todo"): //Fallthrough
case ("deadline"): //Fallthrough

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps remove the comment //Fallthrough since it is redundant. You can consider adding one fallthrough comment at the end of the case. (I see this in a couple of places, so do look into that)

Comment thread src/main/java/Duke/InputParser.java Outdated
return false;
}
}
private boolean isCorrectInput(String[] parsed ) {

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 adding at least a single line space between functions to improve readability

Comment thread src/main/java/Duke/InputParser.java Outdated
}

private String[] parseParameter(String inputString, String optionFlag){
int OPTION_LEN = 4;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Naming conventions of regular variables is pascalCase. Consider using that here instead of all caps.

Comment thread src/main/java/Duke/InputParser.java Outdated

public void parseUserInput(String userInput) throws UnknownCommandException, DukeException {

String[] inputSplitBySpace = userInput.split(" ", 2);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do consider avoiding the usage of magic literals. Store and use the values as final variables instead

Comment thread src/main/java/Duke/InputParser.java Outdated
public void parseUserInput(String userInput) throws UnknownCommandException, DukeException {

String[] inputSplitBySpace = userInput.split(" ", 2);
//assume first word input by user is the 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.

Bring this comment closer to right above the line it describes, so it is clear as to what you are talking about

Comment thread src/main/java/Duke/TaskManager.java Outdated
public class TaskManager {

private static final int RESIZE_FACTOR = 2;
private static int NUM_TASK;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please follow the naming conventions for regular variables. It should be pascalCase for this one since it is not a final variable

# Conflicts:
#	src/main/java/Duke/InputParser.java
Create Jar file

# Conflicts:
#	src/main/java/Duke/TaskManager.java
Add new exceptions
Refactor Exception using Inheritance
Init class for Level 8
Refactor some functions from Duke class into utilities classes
CheahHaoYi and others added 16 commits September 30, 2022 01:55
Refactor functionalities more clearly into the utility classes
Add exception check for wrong option flag
Add find functionality
To push A-MoreOOP tag onto github (missed out earlier)
To create branch for A-JavaDoc (missed out earlier)
Fix minor coding style violations
Fix parser bug for bad option flags
Refactor to replace hardcoded line seperator with java system line separator
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