mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-10 04:01:19 +00:00
<duplicate code> agrega metodo para incrementar calidad de item
This commit is contained in:
parent
640daa2382
commit
a55474f928
@ -12,6 +12,10 @@ class GildedRose
|
|||||||
item.quality = item.quality - 1
|
item.quality = item.quality - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def increase_quality(item)
|
||||||
|
item.quality = item.quality + 1
|
||||||
|
end
|
||||||
|
|
||||||
def update_quality()
|
def update_quality()
|
||||||
@items.each do |item|
|
@items.each do |item|
|
||||||
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
@ -22,16 +26,16 @@ class GildedRose
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if item.quality < 50
|
if item.quality < 50
|
||||||
item.quality = item.quality + 1
|
increase_quality(item)
|
||||||
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
if item.name == "Backstage passes to a TAFKAL80ETC concert"
|
||||||
if item.sell_in < 11
|
if item.sell_in < 11
|
||||||
if item.quality < 50
|
if item.quality < 50
|
||||||
item.quality = item.quality + 1
|
increase_quality(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if item.sell_in < 6
|
if item.sell_in < 6
|
||||||
if item.quality < 50
|
if item.quality < 50
|
||||||
item.quality = item.quality + 1
|
increase_quality(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -53,7 +57,7 @@ class GildedRose
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
if item.quality < 50
|
if item.quality < 50
|
||||||
item.quality = item.quality + 1
|
increase_quality(item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user