mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-19 00:11:35 +00:00
Separate sellIn behavior in separate class
We extract this behavior in a separate interface so we can implement different implementations of it and test them separately. Default behavior is to decrease the sellIn date every iteration by 1
This commit is contained in:
parent
8f6359ad93
commit
5f51644a8c
@ -0,0 +1,15 @@
|
|||||||
|
package com.gildedrose.behavior.sellin;
|
||||||
|
|
||||||
|
import com.gildedrose.Item;
|
||||||
|
|
||||||
|
public class DefaultSellInBehavior implements SellInBehavior {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processSellInUpdate(Item item) {
|
||||||
|
decreaseSellIn(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void decreaseSellIn(Item item) {
|
||||||
|
item.sellIn = item.sellIn - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.gildedrose.behavior.sellin;
|
||||||
|
|
||||||
|
import com.gildedrose.Item;
|
||||||
|
|
||||||
|
public interface SellInBehavior {
|
||||||
|
|
||||||
|
void processSellInUpdate(Item item);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user