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

Add Order-in-Advance feature #202

Merged
merged 17 commits into from
Oct 28, 2020
Merged

Add Order-in-Advance feature #202

merged 17 commits into from
Oct 28, 2020

Conversation

wengfaing
Copy link

Issues resolved:
#128
#129
#198

@wengfaing wengfaing changed the title Wf week11 Add Order-in-Advance feature Oct 27, 2020
e.g. for a command with format `add-i n/NAME q/QUANTITY`, <br>
replace `NAME` and `QUANTITY` with your input: `add-i n/Chicken q/10`.

* In the format of commands, square brackets are to indicate optional fields. The square brackets are not necessary.<br>

Choose a reason for hiding this comment

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

Suggested change
* In the format of commands, square brackets are to indicate optional fields. The square brackets are not necessary.<br>
* In the format of commands, square brackets are to indicate optional fields. The fields in the square brackets are not mandatory to input.<br>

Copy link
Author

Choose a reason for hiding this comment

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

Actually i meant to say that the square brackets themselves are not necessary bc that was what Aileen feedbacked to us

Choose a reason for hiding this comment

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

Iirc that was because Aileen had a misunderstanding between the command format and the actual command. Saying square brackets are not necessary is wrong because if you put them in the actual command then it's wrong

Copy link
Author

Choose a reason for hiding this comment

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

ok fixed in latest commit

Comment on lines +19 to +21
/** {@code Comparator} that returns a ItemComparator */
Comparator<Delivery> DELIVERY_COMPARATOR = new DeliveryEndTimeComparator();

Choose a reason for hiding this comment

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

This doesn't feel like it should belong in the interface, but in the implementation

Copy link
Author

Choose a reason for hiding this comment

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

  1. Remove this highlighted part from DeliveryAddCommand (it's not from your PR but it shouldn't be there haha)

fixed in commit: a7a2dfb

  1. Add colours for the different delivery time left

added in commit: b6740df

long min = Long.parseLong(minutes);
LocalDateTime endTime = LocalDateTime.now().plusMinutes(min);

return new Time(minutes, endTime.format(DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm:ss")));

Choose a reason for hiding this comment

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

It's a little weird how many times you need to format it. Perhaps have the constructor take in a LocalDateTime instead of a String

Copy link
Author

@wengfaing wengfaing Oct 28, 2020

Choose a reason for hiding this comment

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

In one of my earlier commits I made that change, for the constructor to take in a LocalDateTime but that implementation had its own problems, such as every single class that needed to use Time had to import LocalDateTime as well as ensure proper formatting of its inputs before passing into the constructor (or else it would throw a DateTimeParseException).

Hence i reverted it to this implementation where Time takes in a String and all parsing is done within the class

public Time(String minutes, String endTime) {
requireNonNull(minutes, endTime);

LocalDateTime time = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm:ss"));

Choose a reason for hiding this comment

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

You should make the pattern string a constant since it's being used multiple times

Copy link
Author

Choose a reason for hiding this comment

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

replaced with string constant in commit:
dfe617d

Comment on lines 98 to 103
/*
try {
LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm:ss"));
} catch (DateTimeParseException e) {
throw new IllegalValueException(Time.MESSAGE_CONSTRAINTS);
}*/

Choose a reason for hiding this comment

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

what's this commented chunk

Copy link
Author

Choose a reason for hiding this comment

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

For the other parts of the code, this section here is to check if the JSON info is valid (ie. is the data file corrupt). However, this does not work for this implementation of Time, as we are not storing user input, but we are storing the endTime. Hence we cannot pass the endTime field through the same isValidQuantity/isValidName/etc. method, as that regex is used to test user input not to test this.

I removed this because I am handling the parsing inside the Time class

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 just delete it

Copy link
Author

Choose a reason for hiding this comment

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

ok true, fixed in latest commit

Comment on lines 62 to 63
endTime = delivery.getEndTime();
initialize();

Choose a reason for hiding this comment

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

perhaps a better name instead of initialise to make it clear what it's initialising. (Maybe initialiseDeliveryCountdown)

Copy link
Author

Choose a reason for hiding this comment

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

changed to initializeDeliveryCountdown() in commit:
e156dfc

src/main/java/seedu/address/ui/DeliveryCard.java Outdated Show resolved Hide resolved
@saad-haider-pp
Copy link

Could I also request two more things

  1. Remove this highlighted part from DeliveryAddCommand (it's not from your PR but it shouldn't be there haha)
    image

  2. Add colours for the different delivery time left

Comment on lines 35 to 40
/* No such thing as duplicate delivery
@Test
public void execute_duplicateDelivery_throwsCommandException() {
Delivery delivery = model.getDeliveryBook().getDeliveryList().get(0);
assertCommandFailure(new DeliveryAddCommand(delivery), model, DeliveryAddCommand.MESSAGE_DUPLICATE_DELIVERY);
}
}*/

Choose a reason for hiding this comment

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

almost LGTM, can you just remove this test case

Copy link
Author

Choose a reason for hiding this comment

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

fixed in latest commit

Copy link

@saad-haider-pp saad-haider-pp left a comment

Choose a reason for hiding this comment

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

LGTM

@saad-haider-pp saad-haider-pp merged commit fce280d into master Oct 28, 2020
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

2 participants