mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 23:41:27 +00:00
create Sulfuras subclass
create sulfuras subclass and override StorageItem methodes
This commit is contained in:
parent
025c3e4a9a
commit
284a01fac5
@ -9,9 +9,13 @@ public class StorageItem {
|
|||||||
public static StorageItem createItem(Item item) {
|
public static StorageItem createItem(Item item) {
|
||||||
if (item.name.equals(AGED_BRIE)) {
|
if (item.name.equals(AGED_BRIE)) {
|
||||||
return new AgeddBrie(item);
|
return new AgeddBrie(item);
|
||||||
} else if (item.name.equals(BACKSTAGE_PASSES)) {
|
}
|
||||||
|
if (item.name.equals(BACKSTAGE_PASSES)) {
|
||||||
return new BackstagePasses(item);
|
return new BackstagePasses(item);
|
||||||
}
|
}
|
||||||
|
if (item.name.equals(SULFURAS)) {
|
||||||
|
return new Sulfuras(item);
|
||||||
|
}
|
||||||
return new StorageItem(item);
|
return new StorageItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,15 +32,10 @@ public class StorageItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateQuality() {
|
protected void updateQuality() {
|
||||||
if (item.name.equals(SULFURAS)) {
|
decreaseQuality();
|
||||||
return;
|
|
||||||
} else decreaseQuality();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateSelling() {
|
protected void updateSelling() {
|
||||||
if (item.name.equals(SULFURAS)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
item.sellIn--;
|
item.sellIn--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,11 +44,7 @@ public class StorageItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateExpired() {
|
protected void updateExpired() {
|
||||||
if (item.name.equals(SULFURAS)) {
|
decreaseQuality();
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
decreaseQuality();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void increaseQuality() {
|
protected void increaseQuality() {
|
||||||
|
|||||||
16
Java/src/main/java/com/gildedrose/Sulfuras.java
Normal file
16
Java/src/main/java/com/gildedrose/Sulfuras.java
Normal 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() {}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user