Refactor C# projects

This commit is contained in:
Stef Heyenrath committed 2024-05-29 15:01:51 +02:00
1 parent c7e0b4a8d9
commit 6e5067dcb9
33 files changed
+814 -645

No files matched your search

+89
View File
@@ -0,0 +1,89 @@
using System.Collections.Generic;
namespace GildedRoseKata;
public class GildedRose
{
private readonly IList<Item> _items;
public GildedRose(IList<Item> items)
{
_items = items;
}
public void UpdateQuality()
{
for (var i = 0; i < _items.Count; i++)
{
if (_items[i].Name != "Aged Brie" && _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
{
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;
}
}
}
}
}
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
{
_items[i].SellIn = _items[i].SellIn - 1;
}
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;
}
}
}
}
}
}
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
+8
View File
@@ -0,0 +1,8 @@
namespace GildedRoseKata;
public class Item
{
public string Name { get; set; }
public int SellIn { get; set; }
public int Quality { get; set; }
}