mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 09:11:39 +00:00
comments
This commit is contained in:
parent
53cdb7d893
commit
fcabd7e7f8
@ -7,6 +7,9 @@ class GildedRose {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the quality of the items
|
||||
*/
|
||||
public void updateQuality() {
|
||||
for (Item item : items) {
|
||||
updateItemQuality(item);
|
||||
@ -15,6 +18,10 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the quality of the item
|
||||
* @param item the item to update
|
||||
*/
|
||||
private void updateItemQuality(Item item) {
|
||||
if (isSpecialItem(item)) {
|
||||
increaseQuality(item);
|
||||
@ -26,12 +33,20 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the sellIn of the item
|
||||
* @param item the item to update
|
||||
*/
|
||||
private void updateItemSellIn(Item item) {
|
||||
if (!item.name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
item.sellIn--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the expired item
|
||||
* @param item the item to handle
|
||||
*/
|
||||
private void handleExpiredItem(Item item) {
|
||||
if (item.sellIn < 0) {
|
||||
if (item.name.equals("Aged Brie")) {
|
||||
@ -44,22 +59,39 @@ class GildedRose {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the item is a special item
|
||||
* @param item the item to check
|
||||
* @return true if the item is a special item, false otherwise
|
||||
*/
|
||||
private boolean isSpecialItem(Item item) {
|
||||
return item.name.equals("Aged Brie") || item.name.equals("Backstage passes to a TAFKAL80ETC concert");
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the quality of the item
|
||||
* @param item the item to increase the quality
|
||||
*/
|
||||
private void increaseQuality(Item item) {
|
||||
if (item.quality < 50) {
|
||||
item.quality++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the quality of the item
|
||||
* @param item the item to decrease the quality
|
||||
*/
|
||||
private void decreaseQuality(Item item) {
|
||||
if (item.quality > 0 && !item.name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||
item.quality--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the backstage passes
|
||||
* @param item the item to handle
|
||||
*/
|
||||
private void handleBackstagePasses(Item item) {
|
||||
if (item.sellIn < 11) {
|
||||
increaseQuality(item);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user