public SingleBin Add(string category, string room) { SingleBin newBin = new SingleBin(); newBin.Category = category; newBin.Room = room; Add(newBin); return(newBin); }
public bool DeleteBinByCategory(string removeCategory) { if (binLookUp.ContainsKey(removeCategory.ToLower())) { SingleBin removeBin = binLookUp[removeCategory.ToLower()]; bins.Remove(removeBin); binLookUp.Remove(removeCategory.ToLower()); return(true); } else { return(false); } }
public SingleBin GetBin(string binCategory) { SingleBin myBin = binLookUp[binCategory.ToLower()]; return(myBin); //foreach (SingleBin bin in bins) //{ // if (bin.Category.Equals(binCategory, StringComparison.OrdinalIgnoreCase)) // { // return bin; // } //} //return null; }
private void DeleteItemUI() { Console.WriteLine($"You have {binCollection.Count} bins in your collection."); Console.WriteLine(binCollection.DisplayBins()); Console.Write("Which bin would you like to delete an item from? "); string binDeleteItemFrom = Console.ReadLine(); SingleBin bin = binCollection.GetBin(binDeleteItemFrom); if (bin == null) { Console.WriteLine("\nNo matching bin found"); return; } Console.WriteLine($"\nYou have {bin.ItemList.Count} items in {bin}:\n"); foreach (string item in bin.ItemList) { Console.WriteLine(item); } Console.Write("Which item would you like to delete? "); string itemToDelete = Console.ReadLine(); bin.DeleteItemInItemList(itemToDelete); while (true) { Console.Write("\nWould you like to delete another item? "); string deleteAnotherItemYesOrNo = Console.ReadLine(); if (deleteAnotherItemYesOrNo.Equals("yes", StringComparison.OrdinalIgnoreCase)) { Console.Write("\nWhat item would you like to delete? "); itemToDelete = Console.ReadLine(); bin.DeleteItemInItemList(itemToDelete); } else { break; } } }
private void AddItemUI() { Console.WriteLine(binCollection.DisplayBins()); Console.Write("\nWhich bin would you like to add an item to? "); string binAddItemTo = Console.ReadLine(); SingleBin bin = binCollection.GetBin(binAddItemTo); if (bin != null) { Console.Write($"\nWhat item would you like to add to {binAddItemTo}? "); string itemAddToBin = Console.ReadLine(); bin.AddToItemList(itemAddToBin); Console.WriteLine($"\nYour item {itemAddToBin} has been successfully added."); } else { Console.WriteLine("\nNo matching bin found"); } while (true) { Console.Write("\nWould you like to add another item? "); string addAnotherItemYesOrNo = Console.ReadLine(); if (addAnotherItemYesOrNo.Equals("yes", StringComparison.OrdinalIgnoreCase)) { Console.Write("\nWhat is the next item you would like to add? "); string nextItemToAdd = Console.ReadLine(); bin.AddToItemList(nextItemToAdd); Console.WriteLine($"\nYour item {nextItemToAdd} has been successfully added."); } else { break; } } }
private void ViewBinsUI() { Console.WriteLine($"\n\nYou have {binCollection.Count} bins in your collection."); Console.WriteLine(binCollection.DisplayBins()); Console.Write("Would you like to view the contents of a bin? "); string viewItemsYesOrNo = Console.ReadLine(); if (viewItemsYesOrNo.Equals("yes", StringComparison.OrdinalIgnoreCase)) { Console.Write("Which bin would you like to look in? "); string bin = Console.ReadLine(); SingleBin binToLookIn = binCollection.GetBin(bin); Console.WriteLine($"You have {binToLookIn.ItemList.Count} items\n"); foreach (string item in binToLookIn.ItemList) { Console.WriteLine(item); } } }
public void Add(SingleBin bin) { bins.Add(bin); binLookUp.Add(bin.Category.ToLower(), bin); }