Open
Conversation
…ly in the domain-model.md
…ng errors in domain-model.md Last commit for core exercises
…to be able to test properly
ninja-aruna
reviewed
Jan 15, 2025
| public Item createItem(String id) { | ||
| this.id = id; | ||
| if (this.inventory.containsKey(this.id)) { | ||
| if (this.id.startsWith("B")) { |
There was a problem hiding this comment.
You may want to make this case-insensitive
| //Max capacity is 5, so adding should fail after 5 elements are present in the basket list | ||
| Basket basket = new Basket(); | ||
| ItemFactory factory = new ItemFactory(); | ||
| Item item = factory.createItem("BGLP"); |
There was a problem hiding this comment.
It may be better to have an overload for the factory method that creates X number of times: create(ItemType, number)
| //This methods will allow multiple discounts to be applied and likely got this ugly because of it | ||
| //I.e. if there are 18 bagels of the same type, first the 12 bagel discount is given and then the 6 bagel discount for the remaining bagles | ||
| //The coffee discount needs "stand-alone" bagels, so not bagles that are already part of another discount calculation | ||
| public void checkDiscounts() { |
There was a problem hiding this comment.
This can become hard to maintain if other types of discounts are added in hje future. I think it belongs in its own class, and could do with further decomposition into smaller methods.
|
|
||
| } | ||
|
|
||
| public void checkItemTypes() { |
There was a problem hiding this comment.
This method is called 'checkItemTypes' but it also adds items which makes the name a bit misleading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.