| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void updateQuality() {
-
- for (Item item: items) {
-
- //This loop runs at the end of each day
- //SellIn is the value which denotes the number of days we have to sell the item
- //Quality value denotes how values for every item
-
- if (item.getName().equals("Aged Brie")) {
-
- if (item.getQuality() < 50) {
- item.setQuality(item.getQuality() + 1);
- }
-
- } else {
-
- if (item.getQuality() > 0) {
- if (!item.getName().equals("Sulfuras, Hand of Ragnaros")) {
- item.setQuality(item.getQuality() - 1);
- }
- }
- }
-
-
- if (!item.getName().equals("Sulfuras, Hand of Ragnaros")) {
- item.setSellIn(item.getSellIn() - 1);
- }
-
- if (item.getSellIn() < 0) {
- if (!item.getName().equals("Aged Brie")) {
- item.setQuality(item.getQuality() - 1);
- } else {
- if (item.getQuality() < 50) {
- item.setQuality(item.getQuality() + 1);
- }
- }
- }
-
- }
- }
- }
|