mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
create two functions one for decrease and the other to increase quality
This commit is contained in:
parent
cc1a3411d3
commit
733a05da12
@ -7,6 +7,18 @@ class GildedRose {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
private void increaseQuality(Item item) {
|
||||
if (item.quality < 50) {
|
||||
item.quality += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void decreaseQuality(Item item) {
|
||||
if (item.quality > 0) {
|
||||
item.quality -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateQuality() {
|
||||
for (Item item : items) {
|
||||
if (item.name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
@ -15,27 +27,19 @@ class GildedRose {
|
||||
|
||||
if (!item.name.equals("Aged Brie")
|
||||
&& !item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (item.quality > 0) {
|
||||
item.quality -= 1;
|
||||
}
|
||||
decreaseQuality(item);
|
||||
} else {
|
||||
if (item.quality < 50) {
|
||||
item.quality += 1;
|
||||
increaseQuality(item);
|
||||
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (item.sellIn < 11) {
|
||||
increaseQuality(item);
|
||||
}
|
||||
|
||||
if (item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (item.sellIn < 11) {
|
||||
if (item.quality < 50) {
|
||||
item.quality += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.sellIn < 6) {
|
||||
if (item.quality < 50) {
|
||||
item.quality += 1;
|
||||
}
|
||||
}
|
||||
if (item.sellIn < 6) {
|
||||
increaseQuality(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
item.sellIn = item.sellIn - 1;
|
||||
@ -43,16 +47,12 @@ class GildedRose {
|
||||
if (item.sellIn < 0) {
|
||||
if (!item.name.equals("Aged Brie")) {
|
||||
if (!item.name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||
if (item.quality > 0) {
|
||||
item.quality -= 1;
|
||||
}
|
||||
decreaseQuality(item);
|
||||
} else {
|
||||
item.quality -= item.quality;
|
||||
}
|
||||
} else {
|
||||
if (item.quality < 50) {
|
||||
item.quality += 1;
|
||||
}
|
||||
increaseQuality(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user