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

[mid v1.2] Add more validation to UpdateCommand #77

Merged
merged 7 commits into from
Mar 13, 2019

Conversation

jtankw3
Copy link

@jtankw3 jtankw3 commented Mar 12, 2019

Add max quantity to prevent integer overflow.
Add check to UpdateCommand to prevent removing medicine that does not exist.
Improve performance of getNewMedicineExpiry for UpdateCommand class to O(1) most of the time
List stays on current view for more convenient updating after using UpdateCommand.
Improve and add JUnit tests for UpdateCommand

Also removed Address Book Mode and Kevin's part of the user guides to be replaced with more coherent features in future update of UseGuide.

@jtankw3 jtankw3 added the v1.2 For v1.2 project milestone label Mar 12, 2019
@jtankw3 jtankw3 added this to the v1.2 milestone Mar 12, 2019
@jtankw3 jtankw3 added the type.Enhancement An enhancement to an existing story label Mar 12, 2019
@jtankw3 jtankw3 closed this Mar 13, 2019
@jtankw3 jtankw3 reopened this Mar 13, 2019

if (batchToUpdate != null) {
quantity -= batchToUpdate.getQuantity().getNumericValue();
}
quantity += updatedBatch.getQuantity().getNumericValue();

if (quantity > 999999999) {
Copy link

Choose a reason for hiding this comment

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

Use Java's Integer.MAX_VALUE if the intention is to prevent integer overflow.

Copy link
Author

Choose a reason for hiding this comment

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

You're right! Thanks for pointing it out. I will amend it by next PR.

Copy link

@flxffy flxffy left a comment

Choose a reason for hiding this comment

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

Probably want to use Java's Integer.MAX_VALUE to check for overflows instead of hardcoding it, otherwise it looks good!

@flxffy flxffy merged commit 49e82a2 into CS2103-AY1819S2-T12-3:master Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type.Enhancement An enhancement to an existing story v1.2 For v1.2 project milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants