1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
-
- 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")) {
- continue;
- }
-
-
- if (items[i].getName().equals("Aged Brie")) {
- updateAgedBrie(i);
- }else if(items[i].getName().equals("Conjured Item")){
- updateConjuredItem(i);
- } else{
- updateRegularItem(i);
- }
-
-
- if(items[i].getQuality() < 80){
- items[i].setSellIn(items[i].getSellIn() -1);
- }
- }
- }
-
-
-
- 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 updateRegularItem(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);
- }
- }
-
- public void updateConjuredItem(int i){
- if(items[i].getSellIn() > 0 && items[i].getQuality() > 0){
- items[i].setQuality(items[i].getQuality() - 2);
- } else if(items[i].getSellIn() < 0 && items[i].getQuality() > 1){
- items[i].setQuality(items[i].getQuality() - 4);
- }
- }
- }
-
|