GildedRose-Refactoring-Kata/csharpcore/GildedRose/GildedRose.cs
Sarah Ashri a69f02d975 ported previous refactoring to csharpcore project
Made the previous ones in csharp instead by mistake
2024-03-13 09:33:07 +10:00

94 lines
2.4 KiB
C#

using System.Collections.Generic;
namespace GildedRoseKata;
public class GildedRose
{
private readonly IList<Item> _items;
public GildedRose(IList<Item> items)
{
_items = items;
}
public void UpdateQuality()
{
foreach (var item in _items)
{
DailyItemUpdate(item);
}
}
private void DailyItemUpdate(Item item)
{
if (item.Name != "Aged Brie" && 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
{
if (item.Quality < 50)
{
item.Quality = item.Quality + 1;
if (item.Name == "Backstage passes to a TAFKAL80ETC concert")
{
if (item.SellIn < 11)
{
if (item.Quality < 50)
{
item.Quality = item.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)
{
item.Quality = item.Quality + 1;
}
}
}
}
}