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