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")) {
|
if (item.name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.name.equals("Aged Brie")) {
|
if (item.name.equals("Aged Brie")) {
|
||||||
if (item.quality < 50) {
|
increaseQuality(item);
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
} else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
} else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (item.quality < 50) {
|
increaseQuality(item);
|
||||||
item.quality = item.quality + 1;
|
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
|
|
||||||
if (item.sellIn < 11) {
|
if (item.sellIn < 11) {
|
||||||
if (item.quality < 50) {
|
increaseQuality(item);
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.sellIn < 6) {
|
if (item.sellIn < 6) {
|
||||||
if (item.quality < 50) {
|
increaseQuality(item);
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (item.quality > 0) {
|
} else {
|
||||||
item.quality = item.quality - 1;
|
decreaseQuality(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
|
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
if (item.name.equals("Aged Brie")) {
|
if (item.name.equals("Aged Brie")) {
|
||||||
if (item.quality < 50) {
|
increaseQuality(item);
|
||||||
item.quality = item.quality + 1;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
item.quality = item.quality - item.quality;
|
item.quality = item.quality - item.quality;
|
||||||
} else {
|
} else {
|
||||||
if (item.quality > 0) {
|
decreaseQuality(item);
|
||||||
item.quality = item.quality - 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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