mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-10 20:21:26 +00:00
swap ifelse for when
This commit is contained in:
parent
5d1af208f0
commit
ac51ee20e4
@ -6,15 +6,23 @@ class GildedRose(var items: List<Item>) {
|
|||||||
|
|
||||||
fun updateQuality() {
|
fun updateQuality() {
|
||||||
for (i in items.indices) {
|
for (i in items.indices) {
|
||||||
if (items[i].name == "Backstage passes to a TAFKAL80ETC concert") {
|
when (items[i].name) {
|
||||||
updateBackstagePassesQuality(i)
|
"Backstage passes to a TAFKAL80ETC concert" -> {
|
||||||
} else if (items[i].name == "Aged Brie") {
|
updateBackstagePassesQuality(i)
|
||||||
updateAgedBrieQuality(i)
|
}
|
||||||
} else if (items[i].name == "Sulfuras, Hand of Ragnaros") {
|
|
||||||
updateSulfurasQuality(i)
|
"Aged Brie" -> {
|
||||||
} else {
|
updateAgedBrieQuality(i)
|
||||||
downGradeQuality(i)
|
}
|
||||||
if (items[i].sellIn < 1) downGradeQuality(i)
|
|
||||||
|
"Sulfuras, Hand of Ragnaros" -> {
|
||||||
|
updateSulfurasQuality(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
downGradeQuality(i)
|
||||||
|
if (items[i].sellIn < 1) downGradeQuality(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sellItem(i)
|
sellItem(i)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user