diff --git a/csharp/GildedRose.cs b/csharp/GildedRose.cs index 5c514bc5..c60d97a0 100644 --- a/csharp/GildedRose.cs +++ b/csharp/GildedRose.cs @@ -12,82 +12,78 @@ namespace csharp public void UpdateQuality() { - Items.ForEach(item => DailyItemUpdate(item)); - } - - private void DailyItemUpdate(Item item) - { - if (item.Name != "Aged Brie" && item.Name != "Backstage passes to a TAFKAL80ETC concert") + for (var i = 0; i < Items.Count; i++) { - if (item.Quality > 0) + if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert") { - if (item.Name != "Sulfuras, Hand of Ragnaros") + if (Items[i].Quality > 0) { - item.Quality = item.Quality - 1; - } - } - } - else - { - if (item.Quality < 50) - { - item.Quality = item.Quality + 1; - - if (item.Name == "Backstage passes to a TAFKAL80ETC concert") - { - if (item.SellIn < 11) + if (Items[i].Name != "Sulfuras, Hand of Ragnaros") { - if (item.Quality < 50) - { - item.Quality = item.Quality + 1; - } + Items[i].Quality = Items[i].Quality - 1; } - - if (item.SellIn < 6) - { - if (item.Quality < 50) - { - item.Quality = item.Quality + 1; - } - } - } - } - } - - if (item.Name != "Sulfuras, Hand of Ragnaros") - { - item.SellIn = item.SellIn - 1; - } - - if (item.SellIn < 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; - } - } - } - else - { - item.Quality = item.Quality - item.Quality; } } else { - if (item.Quality < 50) + if (Items[i].Quality < 50) { - item.Quality = item.Quality + 1; + Items[i].Quality = Items[i].Quality + 1; + + if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert") + { + if (Items[i].SellIn < 11) + { + if (Items[i].Quality < 50) + { + Items[i].Quality = Items[i].Quality + 1; + } + } + + if (Items[i].SellIn < 6) + { + if (Items[i].Quality < 50) + { + Items[i].Quality = Items[i].Quality + 1; + } + } + } + } + } + + if (Items[i].Name != "Sulfuras, Hand of Ragnaros") + { + Items[i].SellIn = Items[i].SellIn - 1; + } + + if (Items[i].SellIn < 0) + { + if (Items[i].Name != "Aged Brie") + { + if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert") + { + if (Items[i].Quality > 0) + { + if (Items[i].Name != "Sulfuras, Hand of Ragnaros") + { + Items[i].Quality = Items[i].Quality - 1; + } + } + } + else + { + Items[i].Quality = Items[i].Quality - Items[i].Quality; + } + } + else + { + if (Items[i].Quality < 50) + { + Items[i].Quality = Items[i].Quality + 1; + } } } } } - - } }