12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void agedBrieUpdate( int i){
- if(items[i].getSellIn() > 0){
- 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 updateNormalItems(int i){
- if(items[i].getSellIn() > 0){
- 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 updateQuality() {
- for (int i = 0; i < items.length; i++) {
- if(items[i].getName().equals("Aged Brie")){
- agedBrieUpdate(i);
- }
-
-
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- 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);
- }
- }
- }
- }
- }
- }
|