public static void Create(IList <InventoryItem> inventoryList) { string ItemName = ConsoleHelper.ReadString("Enter the Name of the new Item..."); int ItemSellin = ConsoleHelper.ReadInt("Enter the 'Sell In' days of the new Item...", "The 'Sell In' days must be a number! Please try again"); int ItemQuality = ConsoleHelper.ReadInt("Enter the Quality level of the new Item...", "The Quality level must be a number! Please try again"); Dictionary <string, InventoryItem> InventoryChoice = new Dictionary <string, InventoryItem> { { InventoryNames.AgedBrie, new AgedBrie(ItemSellin, ItemQuality) }, { InventoryNames.ChristmasCracker, new ChristmasCracker(ItemSellin, ItemQuality) }, { InventoryNames.FreshItem, new FreshItem(ItemSellin, ItemQuality) }, { InventoryNames.FrozenItem, new FrozenItem(ItemSellin, ItemQuality) }, { InventoryNames.Soap, new Soap(ItemSellin, ItemQuality) } }; if (InventoryChoice.ContainsKey(ItemName)) { inventoryList.Add(InventoryChoice[ItemName]); } else { inventoryList.Add(new InvalidItem(ItemName, ItemSellin, ItemQuality)); } Console.WriteLine($"{ItemName} has been added to your inventory, you now have {inventoryList.Count} items in total"); ConsoleHelper.WriteHorizontalRule(); InventoryMenu.Options(inventoryList); }
static void Main(string[] args) { Console.WriteLine("Welcome back, Allison!"); IList <InventoryItem> InventoryList = new List <InventoryItem>(); InventoryMenu.Options(InventoryList); }
public static void Load(IList <InventoryItem> inventoryList) { bool ConfirmLoad = ConsoleHelper.ReadBool("This remove any existing Inventory, are you sure?"); if (ConfirmLoad) { inventoryList.Clear(); // "Aged Brie 1 1" inventoryList.Add(new AgedBrie(1, 1)); // "Christmas Crackers -1 2" inventoryList.Add(new ChristmasCracker(-1, 2)); // "Christmas Crackers 9 2" inventoryList.Add(new ChristmasCracker(9, 2)); // "Soap 2 2" inventoryList.Add(new Soap(2, 2)); // "Frozen Item -1 55" inventoryList.Add(new FrozenItem(-1, 55)); // "Frozen Item 2 2" inventoryList.Add(new FrozenItem(2, 2)); // "INVALID ITEM 2 2" inventoryList.Add(new InvalidItem("INVALID ITEM", 2, 2)); // "Fresh Item 2 2" inventoryList.Add(new FreshItem(2, 2)); // "Fresh Item -1 5" inventoryList.Add(new FreshItem(-1, 5)); InventoryReader.Read(inventoryList); } else { InventoryMenu.Options(inventoryList); } }
public static void Mature(IList <InventoryItem> inventoryList) { bool ConfirmMature = ConsoleHelper.ReadBool("This will mature every Inventory Item by 1 Day, are you sure?"); if (ConfirmMature) { foreach (InventoryItem inventoryItem in inventoryList) { inventoryItem.MatureOvernight(); } InventoryReader.Read(inventoryList); } else { InventoryMenu.Options(inventoryList); } }
public static void Read(IList <InventoryItem> inventoryList) { if (inventoryList.Count == 0) { Console.WriteLine("You currently have no Items in your Inventory, to add one, select option 2:"); } else { Console.WriteLine("Here is your current inventory:"); ConsoleHelper.WriteHorizontalRule(); foreach (InventoryItem inventoryitem in inventoryList) { Console.WriteLine(inventoryitem.Print()); } ConsoleHelper.WriteHorizontalRule(); Console.WriteLine($"{inventoryList.Count} Item(s) total"); ConsoleHelper.WriteHorizontalRule(); } InventoryMenu.Options(inventoryList); }