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); } if (item.getSellIn() < 0 && 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.getSellIn() < 0) { item.setQuality(item.getQuality() - 1); } } if (!item.getName().equals("Sulfuras, Hand of Ragnaros")) { item.setSellIn(item.getSellIn() - 1); } } } private boolean isNotLegenday(Item item){ return item.getName().equals("Sulfuras, Hand of Ragnaros") ? true : false; } }