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

Syed Omar Zoran iP #67

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

Conversation

zoranabc201
Copy link

No description provided.

Copy link

@ngdeqi ngdeqi left a comment

Choose a reason for hiding this comment

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

Looks ok overall, just small coding standard problems

@@ -1,28 +1,48 @@
import java.util.Scanner;
public class Duke {
Tasks taskList[] = new Tasks[100];
Copy link

Choose a reason for hiding this comment

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

Maybe you can avoid using magic numbers?

void printWelcome() {
System.out.println("Hello I'm Duke\nWhat can I do for you?");
}
void acceptCommands() {
Scanner input = new Scanner(System.in);
String command;
String commandList[] = new String[100];
int noOfCommands = 0;
do {
command = input.nextLine();
if(command.equals("list")) {
Copy link

Choose a reason for hiding this comment

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

Perhaps you can add a space between "if" and "("

unmarkTasks(Integer.parseInt(command.substring(command.lastIndexOf(' ') + 1)));
continue;
}

System.out.println("added: "+command);
Copy link

Choose a reason for hiding this comment

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

Maybe you can add spaces between "added: ", "+" and "command"

public class Tasks {
String taskName;
boolean done;
Tasks() {
Copy link

Choose a reason for hiding this comment

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

Maybe you could add a "public " before the constructor?

Copy link

@wilsonngja wilsonngja left a comment

Choose a reason for hiding this comment

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

Overall great effort. Try to put white space in between expressions and make your function name more meaningful to the task it perform.

}
void markTasks(int taskNumber) {
System.out.println("Nice! I've marked this task as done:");
taskList[taskNumber-1].setDone(true);

Choose a reason for hiding this comment

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

Try to put a space between previous and next text.

continue;
}
if(command.indexOf(' ') > 0 && command.substring(0,command.indexOf(' ')).equals("mark")) {
markTasks(Integer.parseInt(command.substring(command.lastIndexOf(' ') + 1)));

Choose a reason for hiding this comment

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

Since you're only marking one task, don't have to put plural. markTask is suffice.

displayList(noOfCommands);
continue;
}
if(command.indexOf(' ') > 0 && command.substring(0,command.indexOf(' ')).equals("mark")) {

Choose a reason for hiding this comment

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

Try to add a variable to it. Reading the statement can be difficult especially when the condition is long.

taskList[noOfCommands] = new Tasks();
taskList[noOfCommands++].setTaskName(command);
}
while(!command.equals("bye"));

Choose a reason for hiding this comment

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

Try to have a variable for this boolean expression to be more intuitive.

void printWelcome() {
System.out.println("Hello I'm Duke\nWhat can I do for you?");
}
void acceptCommands() {

Choose a reason for hiding this comment

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

Since you're only accepting 1 command, don't have to put plural. acceptCommand is sufficient.

Copy link

@mathanmahe mathanmahe left a comment

Choose a reason for hiding this comment

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

Good work on the implementation! There are some repeated coding standard violations so do be mindful of those. Consider refactoring where needed to improve readability.

void initializeMessage() {
System.out.println("Got it! I've added this task:");
displayMessage();
System.out.println("Now you have "+ TaskManager.noOfTasks +" tasks in the list.");

Choose a reason for hiding this comment

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

As per the Java coding standard it is recommended to have white spaces before and after your "+" operator.

return taskName;
}

public String taskDoneStatus() {

Choose a reason for hiding this comment

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

Names representing methods should be verbs, as per the Java coding standard. getTaskDoneStatus() would be better.


public class Tasks {
String taskName;
boolean done;

Choose a reason for hiding this comment

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

Booleans should be made to sound like booleans, as per the Java coding standard.

}

void acceptInput() {
Scanner SC = new Scanner(System.in);

Choose a reason for hiding this comment

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

Variable names must be in camelCase, fully uppercase names are reserved for constants.


void acceptInput() {
Scanner SC = new Scanner(System.in);
TaskManager TM = new TaskManager();

Choose a reason for hiding this comment

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

As mentioned above, variable names should be in camelCase.

void initializeMessage() {
System.out.println("Got it! I've added this task:");
displayMessage();
System.out.println("Now you have "+ TaskManager.noOfTasks +" tasks in the list.");

Choose a reason for hiding this comment

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

Operators should be surrounded by a space character, as per the Java coding standard.

void notRecognizedException() {
System.out.println("OOPS!!! I'm sorry, but I don't know what that means :-(");
}
void taskOutOfBounds() {

Choose a reason for hiding this comment

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

Can be renamed to taskOutofBoundsException to be consistent with the other methods here.
Code Quality Guideline: Name Well

package Duke;

public class DukeException {
void todoException() {

Choose a reason for hiding this comment

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

Interesting use of methods to display exception messages. Since these are methods, their naming should be represented using verbs. throwTodoException() and so on would be better.

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