12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- this.items = items;
- }
-
- public void updateQuality()
- {
- for(int i=0;i<items.length;i++)
- {
-
- if(items[i].getName().equals("Sulfuras,Hand Of Rangnaros"))
- {
- 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);
- }
- }
- }
-
-
-
|