Created
August 22, 2015 22:02
-
-
Save mayra-cabrera/950ad7e2b3cbc7613625 to your computer and use it in GitHub Desktop.
Gilden rose code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GildedRose | |
def initialize(items) | |
@items = items | |
end | |
def update_quality() | |
@items.each do |item| | |
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert" | |
if item.quality > 0 | |
if item.name != "Sulfuras, Hand of Ragnaros" | |
item.quality = item.quality - 1 | |
end | |
end | |
else | |
if item.quality < 50 | |
item.quality = item.quality + 1 | |
if item.name == "Backstage passes to a TAFKAL80ETC concert" | |
if item.sell_in < 11 | |
if item.quality < 50 | |
item.quality = item.quality + 1 | |
end | |
end | |
if item.sell_in < 6 | |
if item.quality < 50 | |
item.quality = item.quality + 1 | |
end | |
end | |
end | |
end | |
end | |
if item.name != "Sulfuras, Hand of Ragnaros" | |
item.sell_in = item.sell_in - 1 | |
end | |
if item.sell_in < 0 | |
if item.name != "Aged Brie" | |
if item.name != "Backstage passes to a TAFKAL80ETC concert" | |
if item.quality > 0 | |
if item.name != "Sulfuras, Hand of Ragnaros" | |
item.quality = item.quality - 1 | |
end | |
end | |
else | |
item.quality = item.quality - item.quality | |
end | |
else | |
if item.quality < 50 | |
item.quality = item.quality + 1 | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment