1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
-
- 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++) {
- //handles Sulfuras
- if(items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
- continue;}
-
- if(items[i].getName().equals("Aged Brie")){
- agedBrieUpdate(i);
- } else if (items[i].getName().equals("Conjured Mage Water")){
- conjuredItemUpdate(i);
- }else{regularItemUpdate(i);}
-
- if (items[i].getQuality() < 80) {
- items[i].setSellIn(items[i].getSellIn() - 1);
- }
-
- }
-
- }
-
- public void agedBrieUpdate(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 regularItemUpdate(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 conjuredItemUpdate(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);
- }
- }
- }
-
|