mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Refactor method for Quality decrease, increase
This commit is contained in:
parent
7115cd5456
commit
43c9b0db33
@ -15,12 +15,12 @@ class GildedRose {
|
|||||||
return;
|
return;
|
||||||
} else if (item.name.equals("Aged Brie")) {
|
} else if (item.name.equals("Aged Brie")) {
|
||||||
|
|
||||||
plusOneQuilaty_if_less_than_fifth(item);
|
increaseQuality(item);
|
||||||
|
|
||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
|
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
plusOneQuilaty_if_less_than_fifth(item);
|
increaseQuality(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
} else if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
@ -29,11 +29,11 @@ class GildedRose {
|
|||||||
item.quality = item.quality + 1;
|
item.quality = item.quality + 1;
|
||||||
|
|
||||||
if (item.sellIn < 11) {
|
if (item.sellIn < 11) {
|
||||||
plusOneQuilaty_if_less_than_fifth(item);
|
increaseQuality(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.sellIn < 6) {
|
if (item.sellIn < 6) {
|
||||||
plusOneQuilaty_if_less_than_fifth(item);
|
increaseQuality(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,23 +44,23 @@ class GildedRose {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
caculateQuilaty_without_Sulfuras(item);
|
decreaseQuality(item);
|
||||||
item.sellIn = item.sellIn - 1;
|
item.sellIn = item.sellIn - 1;
|
||||||
if (item.sellIn < 0) {
|
if (item.sellIn < 0) {
|
||||||
caculateQuilaty_without_Sulfuras(item);
|
decreaseQuality(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void plusOneQuilaty_if_less_than_fifth(Item item) {
|
private void increaseQuality(Item item) {
|
||||||
if (item.quality < 50) {
|
if (item.quality < 50) {
|
||||||
item.quality = item.quality + 1;
|
item.quality = item.quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void caculateQuilaty_without_Sulfuras(Item item) {
|
private void decreaseQuality(Item item) {
|
||||||
if (item.quality > 0) {
|
if (item.quality > 0) {
|
||||||
item.quality = item.quality - 1;
|
item.quality = item.quality - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user