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

Create commons classes #69

Merged
merged 11 commits into from Oct 9, 2019

Conversation

blimyj
Copy link

@blimyj blimyj commented Oct 8, 2019

Add Item, Event, Reminder & Task classes.

@blimyj
Copy link
Author

blimyj commented Oct 8, 2019

This PR targets issues #60 #61.

Copy link

@sianghwee sianghwee left a comment

Choose a reason for hiding this comment

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

Hello, just some issues with the packaging of the files but other than that it seems fine!

@@ -0,0 +1,112 @@
package seedu.address.model.person;

Choose a reason for hiding this comment

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

Hi, is there a reason why this package is within the person package?

private final LocalDateTime endDateTime;
//Duration chosen over Period as Events are unlikely to exceed a day.
private final Duration duration;
private final Priority priority;

Choose a reason for hiding this comment

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

Is there a reason why you would choose to put the priority in the event and task separately? I foresee problems with setting the priority as they might have different priority. Perhaps we should put it in the item class?

* @param duration A Duration of the event. Defaults to Duration.ZERO if null.
* @param priority A Priority of the event. Defaults to Priority.MEDIUM if null.
*/
public Event(LocalDateTime startDateTime, Duration duration, Priority priority) throws IllegalArgumentException {

Choose a reason for hiding this comment

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

Would it be better to overload the constructor than to allow null to be passed into duration and priority.

if (this.task == null) {
return Optional.empty();
} else {
return Optional.of(this.task);

Choose a reason for hiding this comment

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

Consider using Optional.ofNullable(this.task) to remove the need for the if-else loop.

Comment on lines +224 to +229
private Task task;
private Event event;
private Reminder reminder;

// Data fields
private ItemDescription itemDescription;

Choose a reason for hiding this comment

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

Should all of these fields be initialized to null even before the itemBuilder is run?

Comment on lines +283 to +285
if (newItem.getTask() == null && newItem.getEvent() == null && newItem.getReminder() == null) {
throw new IllegalArgumentException("Task, Event & Reminder cannot all be empty!");
}

Choose a reason for hiding this comment

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

Is there a reason why you do this check here instead of at the constructor level?

Comment on lines +280 to +282
if (newItem.getItemDescription() == null) {
throw new IllegalArgumentException("Description must be provided!");
}

Choose a reason for hiding this comment

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

Should we move this check to the constructor of item instead? Since in all cases, items cannot have a null description.

/**
* Available priority levels for tasks and events.
*/
public enum Priority {

Choose a reason for hiding this comment

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

If I am not wrong, there is a need to implement comparable so that we are able to compare across the enumerations.

* @param priority A Priority of the event. Defaults to Priority.MEDIUM if null.
* @param complete Denotes whether the task has been completed or not. Defaults to false if null.
*/
public Task(Priority priority, Boolean complete) {

Choose a reason for hiding this comment

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

Perhaps we should consider overloading the constructor again so that null will not be passed into the constructor.

}

@Override
public int hashCode() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason for this method? Is it a way to store in storage?

Copy link
Collaborator

@Icesiolz Icesiolz left a comment

Choose a reason for hiding this comment

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

Looks good to merge

}
}

public Priority getPriority() {
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 create a setPriority() method also so that the user can edit the priority level?

@mannggoo mannggoo merged commit 35e0ecf into AY1920S1-CS2103T-T10-3:master Oct 9, 2019
This was referenced Oct 9, 2019
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

4 participants