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

[Cheah Hao Yi] iP #57

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

Conversation

CheahHaoYi
Copy link

Added week 3 iP progress

Copy link

@dhanish265 dhanish265 left a comment

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.

public class Duke {
public static void main(String[] args) {

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

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.

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

public static void listTasks(){

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

System.out.println("What can I do for you?");
}

public static boolean toExit(String userInput) {

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)

System.out.println("Beep boop, now you have " + numTasks + " tasks");
}

public static void addDeadline(String param){

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

Copy link

@kaseykwok kaseykwok left a comment

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.

public class Duke {
public static void main(String[] args) {

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

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.

final String ERROR_OUT_OF_BOUND = "Sorry, the task does not seem to exist :<";
tasks[whichTask].setStatus(done);

if(whichTask > numTasks){

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.

System.out.println("Beep boop, now you have " + numTasks + " tasks");
}

public static void addDeadline(String param){

Choose a reason for hiding this comment

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

Avoid double spacing.

*/

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

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.


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

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.

Copy link

@morbenami1 morbenami1 left a comment

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 :)

public class Duke {
public static void main(String[] args) {

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

Choose a reason for hiding this comment

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

use magic number

}

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

Choose a reason for hiding this comment

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

instead of splitInput- inputSplitedBySpace

private boolean isDone;
private String taskDescription;

private final String STATUS_DONE_ICON = "X";

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

public static void main(String[] args) {

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

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

Copy link

@sevenseasofbri sevenseasofbri left a comment

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. 👍🏽


public static void greetUser() {

final String LOGO = "\n"

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 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?");

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)

System.out.println("What can I do for you?");
}

public static boolean isToExit(String userInput) {

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 on lines 20 to 24
case ("list"): //Fallthrough
case ("mark"): //Fallthrough
case ("unmark"): //Fallthrough
case ("todo"): //Fallthrough
case ("deadline"): //Fallthrough

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)

return false;
}
}
private boolean isCorrectInput(String[] parsed ) {

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

}

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

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.


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

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

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

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

String[] inputSplitBySpace = userInput.split(" ", 2);
//assume first word input by user is the command

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

public class TaskManager {

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

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