mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
Update
This commit is contained in:
parent
c4e187c132
commit
ad8263292a
@ -2,88 +2,77 @@
|
||||
|
||||
namespace csharp
|
||||
{
|
||||
public class GildedRose
|
||||
namespace csharp
|
||||
{
|
||||
IList<Item> Items;
|
||||
public GildedRose(IList<Item> Items)
|
||||
public class GildedRose
|
||||
{
|
||||
this.Items = Items;
|
||||
}
|
||||
|
||||
public void UpdateQuality()
|
||||
{
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
IList<Item> Items;
|
||||
public GildedRose(IList<Item> Items)
|
||||
{
|
||||
if (Items[i].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
this.Items = Items;
|
||||
}
|
||||
|
||||
public void UpdateQuality()
|
||||
{
|
||||
foreach (var item in Items)
|
||||
{
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
}
|
||||
}
|
||||
UpdateItemQuality(item);
|
||||
UpdateItemSellIn(item);
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
private void UpdateItemQuality(Item item)
|
||||
{
|
||||
if (item.Name == "Sulfuras, Hand of Ragnaros")
|
||||
return;
|
||||
|
||||
if (item.Name == "Aged Brie")
|
||||
{
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
IncreaseQuality(item);
|
||||
if (item.SellIn < 0)
|
||||
IncreaseQuality(item);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (item.Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
Items[i].SellIn = Items[i].SellIn - 1;
|
||||
IncreaseQuality(item);
|
||||
|
||||
if (item.SellIn <= 10)
|
||||
IncreaseQuality(item);
|
||||
|
||||
if (item.SellIn <= 5)
|
||||
IncreaseQuality(item);
|
||||
|
||||
if (item.SellIn < 0)
|
||||
item.Quality = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
DecreaseQuality(item);
|
||||
|
||||
if (item.SellIn < 0)
|
||||
DecreaseQuality(item);
|
||||
}
|
||||
|
||||
private void UpdateItemSellIn(Item item)
|
||||
{
|
||||
if (item.Name != "Sulfuras, Hand of Ragnaros")
|
||||
item.SellIn -= 1;
|
||||
}
|
||||
|
||||
private void IncreaseQuality(Item item)
|
||||
{
|
||||
if (item.Quality < 50)
|
||||
item.Quality += 1;
|
||||
}
|
||||
|
||||
private void DecreaseQuality(Item item)
|
||||
{
|
||||
if (item.Quality > 0)
|
||||
item.Quality -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user