123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void updateQuality() {
- for (int i = 0; i < items.length; i++) {
- if (items[i].getName().equalsIgnoreCase("Sulfuras, Hand of Ragnoros")) {
- continue;
- } else if (items[i].getName().equalsIgnoreCase("Aged Brie")) {
- updateBrie(i);
- } else {
- updateItem(i);
- }
-
- if (items[i].getQuality() < 80) {
- items[i].setSellIn(items[i].getSellIn() - 1);
- }
- }
- }
-
-
-
- public void updateBrie(int i) {
- if (items[i].getSellIn() > 0 && items[i].getQuality() <= 49) {
- items[i].setQuality(items[i].getQuality() + 1 );
- } else if (items[i].getSellIn() <= 0 && items[i].getQuality() <= 48) {
- items[i].setQuality(items[i].getQuality() + 2 );
- }
- }
-
- public void updateItem(int i) {
- if (items[i].getSellIn() > 0 && items[i].getQuality() > 0) {
- items[i].setQuality(items[i].getQuality() - 1 );
- } else if (items[i].getSellIn() < 0 && items[i].getQuality() > 1) {
- items[i].setQuality(items[i].getQuality() - 2 );
- }
- }
- }
-
|