From eeb9a00ce7e1199c07cbe6d2719135874fb08c99 Mon Sep 17 00:00:00 2001 From: Jeremie Magnette Date: Sat, 19 Dec 2020 16:37:09 +0100 Subject: [PATCH] Adding code to handle the Conjured Items --- csharpcore/GildedRose.cs | 14 ++++++++++++++ csharpcore/Program.cs | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/csharpcore/GildedRose.cs b/csharpcore/GildedRose.cs index 62f5e109..358e4737 100644 --- a/csharpcore/GildedRose.cs +++ b/csharpcore/GildedRose.cs @@ -14,6 +14,7 @@ namespace csharpcore public const string SULFURA_ITEM = "sulfura"; public const string AGED_BRIE_ITEM = "aged brie"; public const string BACKSTAGE_PASS_ITEM = "backstage pass"; + public const string CONJURED_ITEM = "conjured"; IList Items; @@ -41,6 +42,10 @@ namespace csharpcore { HandleBackstagePassItem(item); } + else if (lowerCaseItemName.Contains(CONJURED_ITEM)) + { + HandleConjuredItem(item); + } else { HandleMiscelaniousItem(item); @@ -80,6 +85,15 @@ namespace csharpcore item.Quality = MIN_QUALITY; } + private void HandleConjuredItem(Item item) + { + if (item.SellIn > 0) + UpdateItemQualityValue(item, -2); + + else + UpdateItemQualityValue(item, -4); + } + private void HandleMiscelaniousItem(Item item) { if (item.SellIn > 0) diff --git a/csharpcore/Program.cs b/csharpcore/Program.cs index ebe4da4a..2a152a52 100644 --- a/csharpcore/Program.cs +++ b/csharpcore/Program.cs @@ -33,7 +33,6 @@ namespace csharpcore SellIn = 5, Quality = 49 }, - // this conjured item does not work properly yet new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6} };