mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-14 22:21:20 +00:00
Refactoring - extract UpdateQuality(Item) to method
This commit is contained in:
parent
4f9209d154
commit
4684969140
@ -12,75 +12,77 @@ namespace csharp
|
||||
|
||||
public void UpdateQuality()
|
||||
{
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
Items.ForEach(item => UpdateQuality(item));
|
||||
}
|
||||
|
||||
private void UpdateQuality(Item item)
|
||||
{
|
||||
if (item.Name != "Aged Brie" && item.Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (item.Quality > 0)
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
if (item.Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
}
|
||||
item.Quality = item.Quality - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Quality < 50)
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
item.Quality = item.Quality + 1;
|
||||
|
||||
if (item.Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
|
||||
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (item.SellIn < 11)
|
||||
{
|
||||
if (Items[i].SellIn < 11)
|
||||
if (item.Quality < 50)
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
}
|
||||
item.Quality = item.Quality + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (Items[i].SellIn < 6)
|
||||
if (item.SellIn < 6)
|
||||
{
|
||||
if (item.Quality < 50)
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
}
|
||||
item.Quality = item.Quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].SellIn = Items[i].SellIn - 1;
|
||||
}
|
||||
if (item.Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
item.SellIn = item.SellIn - 1;
|
||||
}
|
||||
|
||||
if (Items[i].SellIn < 0)
|
||||
if (item.SellIn < 0)
|
||||
{
|
||||
if (item.Name != "Aged Brie")
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie")
|
||||
if (item.Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (item.Quality > 0)
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
if (item.Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
}
|
||||
item.Quality = item.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;
|
||||
}
|
||||
item.Quality = item.Quality - item.Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Quality < 50)
|
||||
{
|
||||
item.Quality = item.Quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user