move specific logic to backstage item

This commit is contained in:
Sallah Kokaina 2019-11-01 19:17:17 +01:00
parent fa1749ec17
commit 0cb4b53cb4
5 changed files with 15 additions and 21 deletions

View File

@ -28,7 +28,7 @@
-[x] long method
-[ ] plain logic
-[ ] complex operations
-[ ] Item properties are public
-[x] Item properties are public
-[x] multiple access by index
## Refactoring actions
@ -39,5 +39,5 @@
-[x] extract boolean methods
-[x] encapsulate methods
-[ ] isolate specific logics
-[ ] move specific logic to backstage
-[x] move specific logic to backstage
-[x] replace items by specific objects in tests

View File

@ -55,9 +55,6 @@ class GildedRose {
private void increaseQuality(Item item) {
item.increaseQuality();
if (item.name.equals(Backstage.BACKSTAGE)) {
item.increaseBackstageQuality();
}
}
private void updateSellIn(Item item) {

View File

@ -7,4 +7,17 @@ public class Backstage extends Item {
public Backstage(int sellIn, int quality) {
super(BACKSTAGE, sellIn, quality);
}
@Override
public void increaseQuality() {
super.increaseQuality();
if (this.sellIn < 11 && this.quality < 50) {
super.increaseQuality();
}
if (this.sellIn < 6 && this.quality < 50) {
super.increaseQuality();
}
}
}

View File

@ -26,14 +26,4 @@ public class Item {
public void increaseQuality() {
this.quality = this.quality + 1;
}
public void increaseBackstageQuality() {
if (this.sellIn < 11 && this.quality < 50) {
this.increaseQuality();
}
if (this.sellIn < 6 && this.quality < 50) {
this.increaseQuality();
}
}
}

View File

@ -7,10 +7,4 @@ public class Sulfuras extends Item {
public Sulfuras(int sellIn, int quality) {
super(SULFURAS, sellIn, quality);
}
/*@Override
public void increaseQuality() {
super.increaseQuality();
}*/
}