[SaiChaitanya13] ip#203
Conversation
choongzhanhong
left a comment
There was a problem hiding this comment.
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.
| currentPosition++; | ||
| }*/ | ||
|
|
||
| else{ //todo or deadline or event --> put together so don't have to repeat the same code thrice |
There was a problem hiding this comment.
I like the fact that you split the if/else blocks quite meaningfully, along with descriptive comments.
| // 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!!!! |
There was a problem hiding this comment.
Perhaps it might be good to indent the multiple line comments to be aligned with the block?
| 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 = "________________________________________________________________________________"; |
There was a problem hiding this comment.
I like that you extracted these as properties. If they're constants, could you give the proper modifiers and variable name as well?
|
|
||
|
|
||
|
|
||
| System.out.println(divider); |
There was a problem hiding this comment.
Could there be fewer new lines here?
| @Override | ||
| public String toString() { // overrides --> print task prints this! |
There was a problem hiding this comment.
Could the comment be indented/spaced closer to the block it's referring to?
| while (! command.equals("bye")){ | ||
| int index = 1; | ||
| if (command.equals("list")){ | ||
| for (int i = 0; i < currentPosition; i++){ // while not null |
There was a problem hiding this comment.
Perhaps a space could be added before the opening braces, like so: else {?
I believe there are multiple occurrences below as well.
ysl-28
left a comment
There was a problem hiding this comment.
Overall, the code is generally readable. However, the use of magic numbers could be reduced.
| } | ||
|
|
||
| else if (command.startsWith("mark")){ // .startsWith(" ") | ||
| int taskNumber = Integer.parseInt(command.substring(5)); |
There was a problem hiding this comment.
Would it be clearer to use a constant instead of a magic number?
| /*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++; | ||
| }*/ |
There was a problem hiding this comment.
Perhaps it would be more readable to remove chunks of commented code?
| System.out.println(divider); | ||
| } | ||
|
|
||
| else if (command.startsWith("unmark")){ |
There was a problem hiding this comment.
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;
}|
|
||
| else if (command.startsWith("deadline")){ | ||
| Task taskBeingAdded = new Task(command.substring(9)); // task + date + slash (Description) | ||
| // filter the description and date |
There was a problem hiding this comment.
I like the use of comments to explain the code when needed.
| Todo todoBeingAdded = new Todo(command.substring(5)); | ||
| listOfThings[currentPosition] = todoBeingAdded; |
There was a problem hiding this comment.
I like that the variable names are clear and follow the coding standard.
Geeeetyx
left a comment
There was a problem hiding this comment.
Overall good work, but you can tidy up the code to make it look like nicer.
| else if (command.startsWith("mark")){ // .startsWith(" ") | ||
| int taskNumber = Integer.parseInt(command.substring(5)); | ||
| // have to parse | ||
| Task currentTask = listOfThings[taskNumber - 1]; |
There was a problem hiding this comment.
Good that variable names follow camel case
| System.out.println(divider); | ||
| } | ||
|
|
||
| else if (command.startsWith("unmark")){ |
There was a problem hiding this comment.
Might be better to use switch case statements here
| } | ||
| } | ||
|
|
||
| else if (command.startsWith("mark")){ // .startsWith(" ") |
There was a problem hiding this comment.
It might be good to refactor these else if statements to be methods
| 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; |
There was a problem hiding this comment.
Clear variable names that are easy to understand
| System.out.println(greeting); | ||
| System.out.println(divider); | ||
|
|
||
| Task[] listOfThings = new Task[100]; // why cannot private static? |
There was a problem hiding this comment.
Perhaps remove comments that are not explaining the code
maanyos
left a comment
There was a problem hiding this comment.
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
|
|
||
| static final int TOTAL_TASKS = 100; | ||
|
|
||
| public static void main(String[] args) { |
There was a problem hiding this comment.
too much happening in main, try to refactor to improve readibility and abstraction
| Task[] listOfThings = new Task[TOTAL_TASKS]; // why cannot private static? | ||
| int currentPosition = 0; // why cannot private static? |
There was a problem hiding this comment.
don't leave comments for yourself in the code
| return (isDone ? "X" : " "); // mark done task with X | ||
| } | ||
|
|
||
| public boolean isDone() { // do we need this |
SaiChaitanya13 pr
No description provided.