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

[Vaishak Anand] iP #248

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

Conversation

VaishakAnand
Copy link

No description provided.

protected Task task;
protected String message;

public Command(String name) {

Choose a reason for hiding this comment

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

Think you can create subclasses for Command such as ListCommand / DeleteCommand to handle the various inputs. Should help to make the code more readable and better abstracted. Think that will help to optimize and shorten your code, and prevent having too many constructors for similar purposes

@Override
public String taskSaver() {
String type = "D";
return type + "/" + super.taskSaver() + "/" + by.format(DateTimeFormatter.ISO_LOCAL_DATE);

Choose a reason for hiding this comment

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

No issues, but just a suggestion to use String.format

Scanner input = new Scanner(System.in);

// Uses user input text and acts accordingly.
loop:

Choose a reason for hiding this comment

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

I have never seen this syntax before? Is it an meant to be commented out?

Copy link
Author

Choose a reason for hiding this comment

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

No it is not! It was meant to break out of the outer while loop from within the switch case, as a normal break would only break out of the switch case.

Read this for more info: https://stackoverflow.com/questions/22823395/java-how-can-i-break-a-while-loop-under-a-switch-statement

Choose a reason for hiding this comment

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

Wow, thanks for sharing man

Command command = ui.parseCommand(line);
ui.lineBreak();

switch (command.name) {

Choose a reason for hiding this comment

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

Great use of switch case, very readable!

*/
public class Event extends Task {

protected LocalDate at;

Choose a reason for hiding this comment

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

I think you can afford to use "private" instead of "protected" since there is not subclass for Event.

public class Task {
protected String description;
protected boolean isDone;

Choose a reason for hiding this comment

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

Just a suggestion: I used enum to create TaskType and use Tasktype as part of the printing (further leverage on Liskov Sub Principle)

System.out.println("Good Job, this task is now done:");
System.out.println(toBeDone);
}

Choose a reason for hiding this comment

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

Javadoc can be added here too

* Removes a task from the list of current tasks.
* @param taskNo Index of task to remove.
*/
void removeFromList(int taskNo) {

Choose a reason for hiding this comment

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

access modifier for your methods can be included

*/
public class Ui {

protected Parser parser;

Choose a reason for hiding this comment

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

I think can be private instead of protected as your Ui class has no subclass

/**
* Returns a line to the user.
*/
public void lineBreak() {

Choose a reason for hiding this comment

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

Like the abstraction for readability!

@kormingsoon
Copy link

Think overall your code has great names, but the access modifiers as well other minor errors can be improved upon! Great effort nonetheless :D

Copy link

@raymondge raymondge 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 found your code quite structured and easy to read. I noted a few minor coding standard violations
too, usually is the naming of the class/variable.

@@ -10,7 +10,7 @@ public Ui() {
this.parser = new Parser();
}

public static String LINE = "___________________________________________________";

Choose a reason for hiding this comment

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

Since the line is not to share with other class, maybe change it to private instead?

String line = input.nextLine();
Command command = ui.parseCommand(line);
ui.lineBreak();
switch (command.name) {

Choose a reason for hiding this comment

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

good use of switch case to list all possible outcome, adding a default may be better

}
}

public void saveTasks() throws IOException {

Choose a reason for hiding this comment

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

saveTasks maybe change to saveTasksToFile to make it more specific

System.out.println("Looks like you have " + this.list.size() + " tasks in total.");
}

void taskDone(int taskNo) {

Choose a reason for hiding this comment

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

we are missing a verb before taskDone, maybe makeTaskDone?

public void run() {
try {
ui.intro();
Scanner input = new Scanner(System.in);

Choose a reason for hiding this comment

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

input is not a good name for Scanner, maybe sc?

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.

None yet

3 participants