Reformat code

This commit is contained in:
Radek 2018-05-09 20:29:33 +02:00
parent 6447d1c3dc
commit 951ca5f313

View File

@ -4,83 +4,87 @@ namespace csharp
{ {
public class GildedRose public class GildedRose
{ {
IList<Item> Items; private readonly IList<Item> _items;
public GildedRose(IList<Item> Items)
{ public GildedRose(IList<Item> items)
this.Items = Items; => _items = items;
}
public void UpdateQuality() public void UpdateQuality()
{ {
for (var i = 0; i < Items.Count; i++) foreach (var item in _items)
{ {
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert") if (item.Name != "Aged Brie"
&& item.Name != "Backstage passes to a TAFKAL80ETC concert")
{ {
if (Items[i].Quality > 0) if (item.Quality > 0)
{ {
if (Items[i].Name != "Sulfuras, Hand of Ragnaros") if (item.Name != "Sulfuras, Hand of Ragnaros")
{ {
Items[i].Quality = Items[i].Quality - 1; item.Quality = item.Quality - 1;
} }
} }
} }
else else
{ {
if (Items[i].Quality < 50) if (item.Quality < 50)
{ {
Items[i].Quality = Items[i].Quality + 1; item.Quality = item.Quality + 1;
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert") if (item.Name == "Backstage passes to a TAFKAL80ETC concert")
{ {
if (Items[i].SellIn < 11) if (item.SellIn < 11)
{ {
if (Items[i].Quality < 50) if (item.Quality < 50)
{ {
Items[i].Quality = Items[i].Quality + 1; item.Quality = item.Quality + 1;
} }
} }
if (Items[i].SellIn < 6) if (item.SellIn < 6)
{ {
if (Items[i].Quality < 50) if (item.Quality < 50)
{ {
Items[i].Quality = Items[i].Quality + 1; item.Quality = item.Quality + 1;
} }
} }
} }
} }
} }
if (Items[i].Name != "Sulfuras, Hand of Ragnaros") if (item.Name != "Sulfuras, Hand of Ragnaros")
{ {
Items[i].SellIn = Items[i].SellIn - 1; item.SellIn = item.SellIn - 1;
} }
if (Items[i].SellIn < 0) if (item.SellIn >= 0)
{ {
if (Items[i].Name != "Aged Brie") continue;
{
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;
} }
if (item.Name != "Aged Brie")
{
if (item.Name != "Backstage passes to a TAFKAL80ETC concert")
{
if (item.Quality <= 0)
{
continue;
}
if (item.Name != "Sulfuras, Hand of Ragnaros")
{
item.Quality = item.Quality - 1;
} }
} }
else else
{ {
Items[i].Quality = Items[i].Quality - Items[i].Quality; item.Quality = item.Quality - item.Quality;
} }
} }
else else
{ {
if (Items[i].Quality < 50) if (item.Quality < 50)
{ {
Items[i].Quality = Items[i].Quality + 1; item.Quality = item.Quality + 1;
}
} }
} }
} }