Skip to content

[SaiChaitanya13] ip#203

Open
SaiChaitanya13 wants to merge 63 commits into
nus-cs2113-AY2223S2:masterfrom
SaiChaitanya13:master
Open

[SaiChaitanya13] ip#203
SaiChaitanya13 wants to merge 63 commits into
nus-cs2113-AY2223S2:masterfrom
SaiChaitanya13:master

Conversation

@SaiChaitanya13

Copy link
Copy Markdown

No description provided.

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

Looks good!
Mainly, with regards to code style, I have pointed out some areas regarding spacing and comments that you may find could be addressed.

Comment thread src/main/java/Buddy.java Outdated
currentPosition++;
}*/

else{ //todo or deadline or event --> put together so don't have to repeat the same code thrice

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 like the fact that you split the if/else blocks quite meaningfully, along with descriptive comments.

Comment thread src/main/java/Buddy.java Outdated
// filter the description and date
String taskWithDate = taskBeingAdded.description;
int indexOfSlash = taskWithDate.indexOf('/');
String taskDescription = taskWithDate.substring(0, (indexOfSlash - 1)); // substring goes to the one before the second index!!!!

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 might be good to indent the multiple line comments to be aligned with the block?

Comment thread src/main/java/Buddy.java Outdated
Comment on lines +8 to +11
String greeting = "Hello there! I'm Buddy\n"
+ "How may I assist you?";
String exitMessage = "Hope I was of help to you! Have a great day and see you again, Buddy :)";
String divider = "________________________________________________________________________________";

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 like that you extracted these as properties. If they're constants, could you give the proper modifiers and variable name as well?

Comment thread src/main/java/Buddy.java Outdated
Comment on lines +115 to +118



System.out.println(divider);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could there be fewer new lines here?

Comment thread src/main/java/Task.java Outdated
Comment on lines +22 to +23
@Override
public String toString() { // overrides --> print task prints this!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could the comment be indented/spaced closer to the block it's referring to?

Comment thread src/main/java/Buddy.java Outdated
Comment on lines +23 to +26
while (! command.equals("bye")){
int index = 1;
if (command.equals("list")){
for (int i = 0; i < currentPosition; i++){ // while not null

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 a space could be added before the opening braces, like so: else {?
I believe there are multiple occurrences below as well.

@ysl-28 ysl-28 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, the code is generally readable. However, the use of magic numbers could be reduced.

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

else if (command.startsWith("mark")){ // .startsWith(" ")
int taskNumber = Integer.parseInt(command.substring(5));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Would it be clearer to use a constant instead of a magic number?

Comment thread src/main/java/Buddy.java Outdated
Comment on lines +54 to +61
/*else { // adding tasks
listOfThings[currentPosition] = new Task(command); // have to write in
//Task t = new Task(command);
System.out.println(divider);
System.out.println("added: " + command);
System.out.println(divider);
currentPosition++;
}*/

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 would be more readable to remove chunks of commented code?

Comment thread src/main/java/Buddy.java Outdated
System.out.println(divider);
}

else if (command.startsWith("unmark")){

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 would be clearer to follow the Java coding standard for writing if-else statements?

if (condition) {
    statements;
} else if (condition) {
    statements;
} else {
    statements;
}

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

else if (command.startsWith("deadline")){
Task taskBeingAdded = new Task(command.substring(9)); // task + date + slash (Description)
// filter the description and date

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 like the use of comments to explain the code when needed.

Comment thread src/main/java/Buddy.java Outdated
Comment on lines +67 to +68
Todo todoBeingAdded = new Todo(command.substring(5));
listOfThings[currentPosition] = todoBeingAdded;

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 like that the variable names are clear and follow the coding standard.

@Geeeetyx Geeeetyx 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 work, but you can tidy up the code to make it look like nicer.

Comment thread src/main/java/Buddy.java Outdated
else if (command.startsWith("mark")){ // .startsWith(" ")
int taskNumber = Integer.parseInt(command.substring(5));
// have to parse
Task currentTask = listOfThings[taskNumber - 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.

Good that variable names follow camel case

Comment thread src/main/java/Buddy.java Outdated
System.out.println(divider);
}

else if (command.startsWith("unmark")){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Might be better to use switch case statements here

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

else if (command.startsWith("mark")){ // .startsWith(" ")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might be good to refactor these else if statements to be methods

Comment thread src/main/java/Buddy.java Outdated
else if (command.startsWith("deadline")){
Task taskBeingAdded = new Task(command.substring(9)); // task + date + slash (Description)
// filter the description and date
String taskWithDate = taskBeingAdded.description;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clear variable names that are easy to understand

Comment thread src/main/java/Buddy.java Outdated
System.out.println(greeting);
System.out.println(divider);

Task[] listOfThings = new Task[100]; // why cannot private static?

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 comments that are not explaining the code

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

please work on the object orientedness in the code.
try to create command class (and subclasses) to refactor logic by different commands. refer to addressbook3 if necessary

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

static final int TOTAL_TASKS = 100;

public static void main(String[] args) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

too much happening in main, try to refactor to improve readibility and abstraction

Comment thread src/main/java/Buddy.java Outdated
Comment on lines +23 to +24
Task[] listOfThings = new Task[TOTAL_TASKS]; // why cannot private static?
int currentPosition = 0; // why cannot private static?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

don't leave comments for yourself in the code

Comment thread src/main/java/Task.java Outdated
return (isDone ? "X" : " "); // mark done task with X
}

public boolean isDone() { // do we need this

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 action naming for method

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