From 75ac4f62637cfdde1006f8643fc00491be750043 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Mon, 31 Aug 2020 21:38:16 +0200 Subject: [PATCH] Rename items in GildedRose --- GildedRose.cs | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/GildedRose.cs b/GildedRose.cs index 0d01990..6de7d65 100644 --- a/GildedRose.cs +++ b/GildedRose.cs @@ -4,82 +4,83 @@ namespace csharpcore { public class GildedRose { - IList Items; - public GildedRose(IList Items) + private readonly IList _items; + + public GildedRose(IList items) { - this.Items = Items; + _items = items; } public void UpdateQuality() { - for (var i = 0; i < Items.Count; i++) + for (var i = 0; i < _items.Count; i++) { - if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert") + if (_items[i].Name != "Aged Brie" && _items[i].Name != "Backstage passes to a TAFKAL80ETC concert") { - if (Items[i].Quality > 0) + if (_items[i].Quality > 0) { - if (Items[i].Name != "Sulfuras, Hand of Ragnaros") + if (_items[i].Name != "Sulfuras, Hand of Ragnaros") { - Items[i].Quality = Items[i].Quality - 1; + _items[i].Quality = _items[i].Quality - 1; } } } else { - if (Items[i].Quality < 50) + if (_items[i].Quality < 50) { - Items[i].Quality = Items[i].Quality + 1; + _items[i].Quality = _items[i].Quality + 1; - if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert") + if (_items[i].Name == "Backstage passes to a TAFKAL80ETC concert") { - if (Items[i].SellIn < 11) + if (_items[i].SellIn < 11) { - if (Items[i].Quality < 50) + if (_items[i].Quality < 50) { - Items[i].Quality = Items[i].Quality + 1; + _items[i].Quality = _items[i].Quality + 1; } } - if (Items[i].SellIn < 6) + if (_items[i].SellIn < 6) { - if (Items[i].Quality < 50) + if (_items[i].Quality < 50) { - Items[i].Quality = Items[i].Quality + 1; + _items[i].Quality = _items[i].Quality + 1; } } } } } - if (Items[i].Name != "Sulfuras, Hand of Ragnaros") + if (_items[i].Name != "Sulfuras, Hand of Ragnaros") { - Items[i].SellIn = Items[i].SellIn - 1; + _items[i].SellIn = _items[i].SellIn - 1; } - if (Items[i].SellIn < 0) + if (_items[i].SellIn < 0) { - if (Items[i].Name != "Aged Brie") + if (_items[i].Name != "Aged Brie") { - if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert") + if (_items[i].Name != "Backstage passes to a TAFKAL80ETC concert") { - if (Items[i].Quality > 0) + if (_items[i].Quality > 0) { - if (Items[i].Name != "Sulfuras, Hand of Ragnaros") + if (_items[i].Name != "Sulfuras, Hand of Ragnaros") { - Items[i].Quality = Items[i].Quality - 1; + _items[i].Quality = _items[i].Quality - 1; } } } else { - Items[i].Quality = Items[i].Quality - Items[i].Quality; + _items[i].Quality = _items[i].Quality - _items[i].Quality; } } else { - if (Items[i].Quality < 50) + if (_items[i].Quality < 50) { - Items[i].Quality = Items[i].Quality + 1; + _items[i].Quality = _items[i].Quality + 1; } } }