mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-16 19:05:05 +00:00
Refactoring c# projects (#544)
Small Refactoring c# projects, e.g. * add days * remove StartupObject * Fix Approval tests for NUnit * Use Environment.NewLine in Xunit tests * Added + fixed README.md * Removed global.json
This commit is contained in:
1 parent
a348b20789
commit
99f2fcbf18
17 files changed
+263
-236
No files matched your search
@@ -4,83 +4,83 @@ namespace GildedRoseKata;
|
||||
|
||||
public class GildedRose
|
||||
{
|
||||
private readonly IList<Item> _items;
|
||||
IList<Item> Items;
|
||||
|
||||
public GildedRose(IList<Item> items)
|
||||
public GildedRose(IList<Item> Items)
|
||||
{
|
||||
_items = items;
|
||||
this.Items = Items;
|
||||
}
|
||||
|
||||
public void UpdateQuality()
|
||||
{
|
||||
for (var i = 0; i < _items.Count; i++)
|
||||
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].Name != "Aged Brie" && Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (_items[i].Quality > 0)
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality - 1;
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_items[i].Quality < 50)
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
|
||||
if (_items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (Items[i].Name == "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (_items[i].SellIn < 11)
|
||||
if (Items[i].SellIn < 11)
|
||||
{
|
||||
if (_items[i].Quality < 50)
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (_items[i].SellIn < 6)
|
||||
if (Items[i].SellIn < 6)
|
||||
{
|
||||
if (_items[i].Quality < 50)
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
_items[i].SellIn = _items[i].SellIn - 1;
|
||||
Items[i].SellIn = Items[i].SellIn - 1;
|
||||
}
|
||||
|
||||
if (_items[i].SellIn < 0)
|
||||
if (Items[i].SellIn < 0)
|
||||
{
|
||||
if (_items[i].Name != "Aged Brie")
|
||||
if (Items[i].Name != "Aged Brie")
|
||||
{
|
||||
if (_items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
if (Items[i].Name != "Backstage passes to a TAFKAL80ETC concert")
|
||||
{
|
||||
if (_items[i].Quality > 0)
|
||||
if (Items[i].Quality > 0)
|
||||
{
|
||||
if (_items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
if (Items[i].Name != "Sulfuras, Hand of Ragnaros")
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality - 1;
|
||||
Items[i].Quality = Items[i].Quality - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality - _items[i].Quality;
|
||||
Items[i].Quality = Items[i].Quality - Items[i].Quality;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_items[i].Quality < 50)
|
||||
if (Items[i].Quality < 50)
|
||||
{
|
||||
_items[i].Quality = _items[i].Quality + 1;
|
||||
Items[i].Quality = Items[i].Quality + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>GildedRoseKata</RootNamespace>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GildedRoseKata;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("OMGHAI!");
|
||||
|
||||
IList<Item> items = new List<Item>
|
||||
{
|
||||
new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
|
||||
new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
|
||||
new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
|
||||
new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
|
||||
new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = -1, Quality = 80},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 15,
|
||||
Quality = 20
|
||||
},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 10,
|
||||
Quality = 49
|
||||
},
|
||||
new Item
|
||||
{
|
||||
Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
SellIn = 5,
|
||||
Quality = 49
|
||||
},
|
||||
// this conjured item does not work properly yet
|
||||
new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
|
||||
};
|
||||
|
||||
var app = new GildedRose(items);
|
||||
|
||||
int days = 2;
|
||||
if (args.Length > 0)
|
||||
{
|
||||
days = int.Parse(args[0]) + 1;
|
||||
}
|
||||
|
||||
for (var i = 0; i < days; i++)
|
||||
{
|
||||
Console.WriteLine("-------- day " + i + " --------");
|
||||
Console.WriteLine("name, sellIn, quality");
|
||||
for (var j = 0; j < items.Count; j++)
|
||||
{
|
||||
Console.WriteLine(items[j].Name + ", " + items[j].SellIn + ", " + items[j].Quality);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
app.UpdateQuality();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user