internal static void AddNewCandy(CandyStorage db, List <CandyStorage> candyOwners) { var addMenu = new View(); Console.Write(addMenu.GetFullMenu()); Console.WriteLine("Might you know the name of the candy you wish to add?"); var candyName = Console.ReadLine().ToString(); Console.Write(addMenu.GetFullMenu()); Console.WriteLine("And might you know the manufacturer's name of the candy you wish to add?"); var candyManufacturer = Console.ReadLine().ToString(); Console.Write(addMenu.GetFullMenu()); Console.WriteLine("And might you know the flavor profile of the candy you wish to add?"); var candyFlavor = Console.ReadLine().ToString(); var newCandy = new Candy(candyName, candyFlavor, candyManufacturer); db.addCandy(newCandy); Console.Write(addMenu.GetFullMenu()); Console.WriteLine($"Now you own the candy {newCandy.Name}."); Console.WriteLine(); Console.WriteLine("Press enter to continue."); Console.ReadKey(); var exit = false; while (!exit) { var userInput = MainMenu(); exit = TakeActions(db, userInput, candyOwners); } }
internal static void TradeCandy(CandyStorage myStuff, List <CandyStorage> candyOwners) { List <string> nameList = new List <string>(); foreach (CandyStorage cstorage in candyOwners) { nameList.Add(cstorage.Owner); } var menu = new View(); menu.AddMenuText("Enter a candy owner's name to trade with."); menu.AddMenuText("Press Esc to exit."); Console.Write(menu.GetFullMenu()); var userOption = Console.ReadLine().ToLower(); Console.WriteLine(userOption); if (nameList.Contains(userOption)) { var otherOwner = candyOwners.Where(candies => candies.Owner == userOption).ToList()[0]; var otherNameArray = otherOwner.Owner.ToCharArray(); otherNameArray[0] = Char.ToUpper(otherNameArray[0]); var otherName = string.Join("", otherNameArray); menu.AddMenuText($"Select a candy number from {otherName}'s list below."); writeCandies(otherOwner.Candies, menu); Console.WriteLine(menu.GetFullMenu()); var otherOption = Int32.Parse(Console.ReadLine()); var menu2 = new View(); menu2.AddMenuText("Select a candy number from your list below."); writeCandies(myStuff.Candies, menu2); Console.Write(menu2.GetFullMenu()); var myOption = Int32.Parse(Console.ReadLine()); Console.WriteLine($"You traded your {myStuff.Candies[myOption - 1].Name} for {otherName}'s {otherOwner.Candies[otherOption - 1].Name}. Press enter to continue."); otherOwner.addCandy(myStuff.Candies[myOption - 1]); myStuff.addCandy(otherOwner.Candies[otherOption - 1]); otherOwner.Candies.RemoveAt(otherOption - 1); myStuff.Candies.RemoveAt(myOption - 1); myStuff.orderCandy(); otherOwner.orderCandy(); } else { menu.AddMenuText("That name was not found. Press enter to continue"); Console.WriteLine(menu.GetFullMenu()); } Console.ReadLine(); var exit = false; while (!exit) { var userInput = MainMenu(); exit = TakeActions(myStuff, userInput, candyOwners); } }