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++) { // each if/else handles each specific item
- if (items[i].getName().equals("Sulfuras, Hand of Ragnoros")) {
- continue;
- }
- if (items[i].getName().equals("Aged Brie")) {
- updateAgedBrie(i);
- } else updateNormalItem(i);
- }
- }
-
- public void updateAgedBrie(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 updateNormalItem(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 updateConjuredItem(int i) {
- if (items[i].getSellIn() > 0 && items[i].getQuality() <= 50){
- items[i].setQuality(items[i].getQuality() - 1);
- }
- if (items[i].getSellIn() <= 0 && items[i].getQuality() <= 50){
- items[i].setQuality(items[i].getQuality() - 4);
- }
- }
- }
|