This commit is contained in:
Voldart 2023-04-23 16:04:48 +03:00 committed by GitHub
parent c4e187c132
commit ad8263292a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}
}
}
}