create Sulfuras subclass

create sulfuras subclass and override StorageItem methodes
This commit is contained in:
Trobax 2022-11-23 17:51:26 +01:00
parent 025c3e4a9a
commit 284a01fac5
2 changed files with 23 additions and 12 deletions

View File

@ -9,9 +9,13 @@ public class StorageItem {
public static StorageItem createItem(Item item) {
if (item.name.equals(AGED_BRIE)) {
return new AgeddBrie(item);
} else if (item.name.equals(BACKSTAGE_PASSES)) {
}
if (item.name.equals(BACKSTAGE_PASSES)) {
return new BackstagePasses(item);
}
if (item.name.equals(SULFURAS)) {
return new Sulfuras(item);
}
return new StorageItem(item);
}
@ -28,15 +32,10 @@ public class StorageItem {
}
protected void updateQuality() {
if (item.name.equals(SULFURAS)) {
return;
} else decreaseQuality();
decreaseQuality();
}
protected void updateSelling() {
if (item.name.equals(SULFURAS)) {
return;
}
item.sellIn--;
}
@ -45,11 +44,7 @@ public class StorageItem {
}
protected void updateExpired() {
if (item.name.equals(SULFURAS)) {
return;
} else {
decreaseQuality();
}
decreaseQuality();
}
protected void increaseQuality() {

View File

@ -0,0 +1,16 @@
package com.gildedrose;
public class Sulfuras extends StorageItem {
public Sulfuras(Item item) {
super(item);
}
@Override
protected void updateQuality() {}
@Override
protected void updateSelling() {}
@Override
protected void updateExpired() {}
}