mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
extract increaseQuality & decreaseQuality function
This commit is contained in:
parent
e224e973d6
commit
4cfe62665d
@ -17,47 +17,47 @@ class GildedRose {
|
||||
if (item.name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.name.equals("Aged Brie")) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
increaseQuality(item);
|
||||
} else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
|
||||
increaseQuality(item);
|
||||
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (item.sellIn < 11) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
increaseQuality(item);
|
||||
}
|
||||
|
||||
if (item.sellIn < 6) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
increaseQuality(item);
|
||||
}
|
||||
}
|
||||
} else if (item.quality > 0) {
|
||||
item.quality = item.quality - 1;
|
||||
} else {
|
||||
decreaseQuality(item);
|
||||
}
|
||||
|
||||
item.sellIn = item.sellIn - 1;
|
||||
|
||||
if (item.sellIn < 0) {
|
||||
if (item.name.equals("Aged Brie")) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
increaseQuality(item);
|
||||
} else {
|
||||
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
item.quality = item.quality - item.quality;
|
||||
} else {
|
||||
if (item.quality > 0) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
decreaseQuality(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decreaseQuality(Item item) {
|
||||
if (item.quality > 0) {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void increaseQuality(Item item) {
|
||||
if (item.quality < 50) {
|
||||
item.quality = item.quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user