Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. class GildedRose {
  2.  
  3. private static final int LOWEST_QUALITY_VALUE_POSSIBLE = 0;
  4. Item[] items;
  5.  
  6. public GildedRose(Item[] items) {
  7. this.items = items;
  8. }
  9.  
  10. public void updateQuality() {
  11. for (Item item : items) {
  12. customisedItem(item).updateState();
  13. if (hasReachedLowestQualityValue(item)) {
  14. item.quality = LOWEST_QUALITY_VALUE_POSSIBLE;
  15. } else if (hasReachedHighestQualityValue(item)) {
  16. item.quality =
  17. QualityValues.highestValuePossible(item);
  18. }
  19. }
  20. }
  21.  
  22. private CustomisedItem customisedItem(Item item) {
  23. return new CustomisedItemFactory(item).customiseItem(item);
  24. }
  25.  
  26. private boolean hasReachedLowestQualityValue(Item item) {
  27. return item.quality < LOWEST_QUALITY_VALUE_POSSIBLE;
  28. }
  29.  
  30. private boolean hasReachedHighestQualityValue(Item item) {
  31. return item.quality >
  32. QualityValues.highestValuePossible(item);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement