12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
-
- 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("Aged Brie")){
- if(items[i].getQuality() < 50){
- items[i].setQuality(items[i].getQuality() + 1);
- }
- if(items[i].getSellIn() < 0 && items[i].getQuality() < 50){
- items[i].setQuality(items[i].getQuality() + 1);
- }
- } else if(items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
- items[i].setQuality(items[i].getQuality() + 0);
-
- } else if(items[i].getName().equals("Conjured Sword")){
- if(items[i].getSellIn() > 0 && items[i].getQuality() > 0){
- items[i].setQuality(items[i].getQuality() - 2);
- }
- if(items[i].getSellIn() <= 0 && items[i].getQuality() > 0){
- items[i].setQuality(items[i].getQuality() - 4);
- }
-
- }else {
- if(items[i].getSellIn() > 0 && items[i].getQuality() > 0){
- items[i].setQuality(items[i].getQuality() - 1);
- }
- if(items[i].getSellIn() <= 0 && items[i].getQuality() > 0){
- items[i].setQuality(items[i].getQuality() - 2);
- }
- }
-
- if(items[i].getQuality() < 80){
- items[i].setSellIn(items[i].getSellIn() - 1);
- }
- }
- }
- }
-
|