mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Add backstagePasses to switch/case
This commit is contained in:
parent
a631413208
commit
069708dce9
@ -26,6 +26,9 @@ class GildedRose {
|
||||
case SULFURAS:
|
||||
handleSulfuras(item);
|
||||
return;
|
||||
case BACKSTAGE_PASSES:
|
||||
handleBackstagePasses(item);
|
||||
return;
|
||||
}
|
||||
if (!item.name.equals(AGED_BRIE)
|
||||
&& !item.name.equals(BACKSTAGE_PASSES)) {
|
||||
@ -77,6 +80,25 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleBackstagePasses(Item item) {
|
||||
// todo: make it so these items can't be initialized with over 50
|
||||
if (item.sellIn == 0) {
|
||||
item.quality = 0;
|
||||
return;
|
||||
}
|
||||
if (item.quality == 50) {
|
||||
return;
|
||||
}
|
||||
if (item.sellIn <= 10) {
|
||||
if (item.sellIn <= 5) {
|
||||
item.quality += 3;
|
||||
} else {
|
||||
item.quality += 2;
|
||||
}
|
||||
}
|
||||
item.sellIn -= 1;
|
||||
}
|
||||
|
||||
private static void handleSulfuras(Item item) {
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user