1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
-
- public class Inventory {
- private Item[] items;
-
- public Inventory(Item[] items) {
- super();
- this.items = items;
- }
-
- public void updateInventory() {
- for (int i = 0; i < items.length; i++) {
- if(items[i].getName().equals("Sulfuras, Hand of Ragnaros")){
- break;
- } else {
- updateQuality(items[i]);
- updateSellInDays(items[i]);
- if (items[i].getSellIn() < 0) {
- updateExpiredItems(items[i]);
- }
- }
- }
- }
-
- public void updateQuality(Item item){
- if (item.getName().equals("Aged Brie")){
- if (item.getQuality() < 50) {
- increaseQualityBy1(item);
- }
- } else if (item.getName().equals("Backstage passes to a TAFKAL80ETC concert")) {
- if (item.getQuality() < 50) {
- increaseQualityBy1(item);
- //level 3 - item type
- if (item.getName() == "Backstage passes to a TAFKAL80ETC concert") {
- //level 4 - sell in date
- if (item.getSellIn() < 11) {
- //level 5 - quality
- if (item.getQuality() < 50) {
- increaseQualityBy1(item);
- }
- }
- //level 4 - sell in date
- if (item.getSellIn() < 6) {
- //level 5 - quality
- if (item.getQuality() < 50) {
- increaseQualityBy1(item);
- }
- }
- }
- }
- //level 1 - item type
- } else if (item.getQuality() > 0) {
- reduceQualityBy1(item);
- }
- }
-
- public void updateSellInDays(Item item){
- item.setSellIn(item.getSellIn() - 1);
- }
-
- public void updateExpiredItems(Item item){
- if (item.getName().equals("Aged Brie") && item.getQuality() < 50) {
- increaseQualityBy1(item);
- } else if (item.getName().equals("Backstage passes to a TAFKAL80ETC concert")){
- setQualityTo0(item);
- } else if (item.getQuality() > 0) {
- reduceQualityBy1(item);
- }
- }
-
- public void reduceQualityBy1(Item item){
- item.setQuality(item.getQuality() -1);
- }
-
- public void increaseQualityBy1(Item item){
- item.setQuality(item.getQuality() + 1);
- }
-
- public void setQualityTo0(Item item){
- item.setQuality(item.getQuality() - item.getQuality());
- }
-
- }
|