GildedRose-Refactoring-Kata/Java/src/main/java/com/gildedrose/GildedRose.java
turndownfawad 33f9bc4d5f intermediate refactor
it's not what i was hoping for. my preferred solution would be valid/acceptable, but i would have had to change all the tests. ain't nobody got time for that rn. :D
2023-07-07 17:33:46 +02:00

30 lines
780 B
Java

package com.gildedrose;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
class GildedRose {
Item[] items;
public GildedRose(Item[] items) {
this.items = items;
}
public void updateQuality() {
Arrays.stream(items).forEach(this::updateQuality);
}
public void updateQuality(Item item) {
if (item.name.equals("Aged Brie")) {
AgedBrieStrategy.INSTANCE.applyTo(item);
} else if (item.name.startsWith("Backstage passes")) {
BackstagePassesStrategy.INSTANCE.applyTo(item);
} else if (item.name.startsWith("Conjured")) {
ConjuredStrategy.INSTANCE.applyTo(item);
} else {
DefaultStrategy.INSTANCE.applyTo(item);
}
}
}