Categorize

Had to do something about the names.
This commit is contained in:
Emmanuel 2021-04-28 01:39:22 +02:00
parent faa8254fab
commit e47d9f3392

View File

@ -24,16 +24,16 @@ namespace csharp
foreach (var Item in Items) // Changed this to a simpler loop foreach (var Item in Items) // Changed this to a simpler loop
{ {
//Console.WriteLine(Item.Name); //Console.WriteLine(Item.Name);
switch (Item.Name) switch (Categorize(Item.Name))
{ {
case "Aged Brie": case 1:
CalculateSpecialItemQuality(Item); CalculateSpecialItemQuality(Item);
break; break;
case "Sulfuras, Hand of Ragnaros": case 2:
CalculateLegendaryItemQuality CalculateLegendaryItemQuality
(Item, 0, 0); (Item, 0, 0);
break; break;
case "Conjured Mana Cake": case 3:
CalculateItemQuality(Item, 4, 0); CalculateItemQuality(Item, 4, 0);
break; break;
default: default:
@ -116,13 +116,33 @@ namespace csharp
public void ReduceSellIn(Item item) //This will take care of reducing the number of days after each day public void ReduceSellIn(Item item) //This will take care of reducing the number of days after each day
{ {
if (item.SellIn >= 1) //if (item.SellIn >= 1)
{ {
item.SellIn = item.SellIn - 1; item.SellIn = item.SellIn - 1;
} }
} }
// Here is an attempt to categorize the items since am not allowed to touch the items class
public int Categorize(String itemName) //This will take care of reducing the number of days after each day
{
int categoryID;
switch (itemName)
{
case string n when n.Contains("Aged Brie"):
categoryID = 1;
break;
case string n when n.Contains("Sulfuras"):
categoryID = 2;
break;
case string n when n.Contains("Conjured"):
categoryID = 3;
break;
default:
categoryID = 4;
break;
}
return categoryID;
}
} }
} }