mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
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
30 lines
780 B
Java
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);
|
|
}
|
|
}
|
|
}
|