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:
Bjorn Misseghers 2021-04-13 08:47:35 +02:00
parent 8f6359ad93
commit 5f51644a8c
2 changed files with 23 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -0,0 +1,8 @@
package com.gildedrose.behavior.sellin;
import com.gildedrose.Item;
public interface SellInBehavior {
void processSellInUpdate(Item item);
}