1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
-
- 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().equals("Sulfuras, Hand of Ragnaros")) {
- //items[i].setSellIn(items[i].getSellIn() - 1);
- continue;
- }
-
- if (!items[i].getName().equals("Aged Brie")) {
- regItemUpdate();
- // if (items[i].getQuality() > 0) {
- // if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- // items[i].setQuality(items[i].getQuality() - 1);
- // }
- // }
- } else {agedBrieUpdate();
- // if (items[i].getQuality() < 50) {
- // items[i].setQuality(items[i].getQuality() + 1);
- // }
- }
-
-
- if(items[i].getQuality() < 80){
- items[i].setSellIn( items[i].getSellIn() - 1);
- }
-
- // if (items[i].getSellIn() < 0) {
- // if (!items[i].getName().equals("Aged Brie")) {
- // items[i].setQuality(items[i].getQuality() - 1);
- // } else {
- // if (items[i].getQuality() < 50) {
- // items[i].setQuality(items[i].getQuality() + 1);
- // }
- // }
- // }
- }
- }
-
- public void agedBrieUpdate() {
- int i = 0;
- 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 regItemUpdate() {
- int i = 0;
- 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);
- }
-
- }
-
- }
|