| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void updateQuality() {
- for (Item item: items) {
-
-
- //Quality//////////////////////////////////////////////////
- //"Aged Brie" actually increases in Quality the older it gets
- 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);
- }
- }
- }
-
- }
- }
- }
|