| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
-
- 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("Backstage passes to a TAFKAL80ETC concert")){
- increaseQualityByOne(i);
- increaseQualityForBackstagePasses(i);
- }else if(items[i].getName().equals("Aged Brie")){
- increaseQualityByOne(i);
- }else{
- if (items[i].getQuality() > 0) {
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- items[i].setQuality(items[i].getQuality() - 1);
- }
- }
- }
-
- 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")) {
- if (!items[i].getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
- if (items[i].getQuality() > 0) {
- if (!items[i].getName().equals("Sulfuras, Hand of Ragnaros")) {
- items[i].setQuality(items[i].getQuality() - 1);
- }
- }
- } else {
- items[i].setQuality(items[i].getQuality()
- - items[i].getQuality());
- }
- } else {
- increaseQualityByOne(i);
- }
- }
-
- }
- }
-
- public void increaseQualityByOne(int i){
- if(items[i].getQuality() < 50){
- items[i].setQuality(items[i].getQuality() + 1);
- }
- }
-
- public void increaseQualityForBackstagePasses(int i){
- if(items[i].getSellIn() < 11) {
- increaseQualityByOne(i);
- }
- if(items[i].getSellIn() < 6){
- increaseQualityByOne(i);
- }
- }
- }
|