internal static void AddNewCandy(CandyStorage db, List <string> FlavorList) { Console.WriteLine("What is the name of your candy?"); string Name = Console.ReadLine().ToString(); Console.WriteLine("Who is the manufacturer of your candy?"); string Manufacturer = Console.ReadLine().ToString(); Console.WriteLine("Choose your candy flavor: "); foreach (string flavor in FlavorList) { Console.WriteLine(flavor); } string Flavor = Console.ReadLine().ToLower(); Console.WriteLine("When did you buy this candy? [EX] 2010, 12, 23"); Console.WriteLine("Enter Year:"); int Year = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Month:"); int Month = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Day:"); int Day = Convert.ToInt32(Console.ReadLine()); var DateReceived = new DateTime(Year, Month, Day); var newCandy = new Candy(Name, Manufacturer, Flavor, DateReceived); db.SaveNewCandy(newCandy); Console.WriteLine($"Now you own the candy {newCandy.Name}"); Console.ReadKey(); }
private static void EatRandomCandy(CandyStorage db) { Console.WriteLine("Here is a list of flavors that are available:"); db.PrintFlavorList(); Console.WriteLine("Choose one flavor by typing it in and hitting enter to eat a random candy of that flavor!"); db.FindRandomCandy(); }
private static bool TakeActions(CandyStorage db, ConsoleKeyInfo userInput, int userId, Users user) { Console.Write(Environment.NewLine); if (userInput.Key == ConsoleKey.Escape) { return(true); } var selection = userInput.KeyChar.ToString(); switch (selection) { case "1": AddCandyMenu.AddCandyMenus(db, userId); break; case "2": EatCandyMenu.AddEatCandyMenu(db, userId); break; case "3": EatRandomCandyMenu.AddRandomCandyMenu(db, userId); break; case "4": TradeCandyMenu.AddTradeCandyMenu(db, userId, user, candyUsers); break; default: return(true); } return(false); }
private static void EatRandomCandy(CandyStorage db) { var list = db.allTheDefaultCandies().OrderBy(x => x.DateReceived); Console.WriteLine("Here are your candies"); foreach (var candy in list) { Console.WriteLine($"{candy.Name} : {candy.Manufacturer} : {candy.Flavor} : {candy.DateReceived}"); } var candyList = db.allTheDefaultCandies(); Console.WriteLine("Would you like to eat a random piece of candy based on flavor?"); var eatingCandyInput = Console.ReadLine(); var filterCandies = candyList.Where(candy => candy.Flavor == eatingCandyInput).ToList(); Random random = new Random(); int randnum = random.Next(0, filterCandies.Count); candyList.RemoveAt(randnum); var userInput = MainMenu(); var exit = false; exit = TakeActions(db, userInput); }
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); } }
public static bool TakeActions(CandyStorage db, ConsoleKeyInfo userInput) { Console.Write(Environment.NewLine); if (userInput.Key == ConsoleKey.Escape) { return(true); } var selection = userInput.KeyChar.ToString(); switch (selection) { case "1": PickUser(db); break; case "2": AddNewCandy(db); break; case "3": EatCandy(db); break; case "4": EatRandomCandy(db); break; default: return(true); } return(true); }
internal static void AddNewCandy(CandyStorage db) { // Get candy type var candyTypes = db.GetCandyTypes(); var newCandyMenu = new View() .AddMenuText("What type of candy did you get?") .AddMenuOptions(candyTypes); Console.Write(newCandyMenu.GetFullMenu()); var selectedCandyType = Console.ReadKey().KeyChar.ToString(); var candyTypeIndex = int.Parse(selectedCandyType); var candyType = candyTypes[candyTypeIndex - 1]; // Get candy name var candyNames = db.GetCandyNames(candyType); var candyNameMenu = new View() .AddMenuText("What is the name of the candy?") .AddMenuOptions(candyNames) .AddMenuText("Or enter a new name"); Console.Write(candyNameMenu.GetFullMenu()); int candyNameIndex; var candyName = Console.ReadLine(); int.TryParse(candyName, out candyNameIndex); if (candyNameIndex > 0) { candyName = candyNames[candyNameIndex - 1]; } // Get candy manufacturer var candyMakes = db.GetCandyMakes(); var candyMakeMenu = new View() .AddMenuText("Who makes the candy?") .AddMenuOptions(candyMakes) .AddMenuText("Or enter a new manufacturer"); Console.Write(candyMakeMenu.GetFullMenu()); int candyMakeIndex; var candyMake = Console.ReadLine(); int.TryParse(candyMake, out candyMakeIndex); if (candyMakeIndex > 0) { candyMake = candyMakes[candyMakeIndex - 1]; } // Make new candy from inputs and save var candyToAdd = new Candy { Name = candyName, Flavor = candyType, Manufacturer = candyMake, ReceivedOn = DateTime.Now }; db.SaveNewCandy(candyToAdd); }
private static void TradeCandy(CandyStorage db) { var tradeCandyMenu = new View() .AddMenuText("Choose a trade request") .AddMenuOptions(otherUsers.Select(u => u.WantsToTrade()).ToList()); Console.Write(tradeCandyMenu.GetFullMenu()); var chosenUser = Console.ReadKey().KeyChar.ToString(); var chosenIndex = int.Parse(chosenUser); var otherUser = otherUsers[chosenIndex - 1]; var userCandyMenu = new View() .AddMenuText($"Request a candy from {otherUser.Name}") .AddMenuOptions(otherUser.Candies.Select(c => c.Name).ToList()); Console.Write(userCandyMenu.GetFullMenu()); var chosenCandy = Console.ReadKey().KeyChar.ToString(); var candyIndex = int.Parse(chosenCandy); var otherCandy = otherUser.Candies[candyIndex - 1]; var yourCandyMenu = new View() .AddMenuText($"Which candy do you want to trade for {otherCandy.Name}?") .AddMenuOptions(you.Candies.Select(c => c.Name).ToList()); Console.Write(yourCandyMenu.GetFullMenu()); var yourChosenCandy = Console.ReadKey().KeyChar.ToString(); var yourIndex = int.Parse(yourChosenCandy); var yourCandy = you.Candies[yourIndex - 1]; you.TradeCandy(otherCandy, you.Candies.FindIndex(c => c.Name == yourCandy.Name)); otherUser.TradeCandy(yourCandy, otherUser.Candies.FindIndex(c => c.Name == otherCandy.Name)); }
internal static void AddNewCandy(CandyStorage db) { // Candy Types // var candyTypes = db.GetCandyTypes(); var newCandyMenuTypes = new View() .AddMenuText("What type of candy did you get?") .AddMenuOptions(candyTypes); Console.Write(newCandyMenuTypes.GetFullMenu()); var selectedCandyType = Console.ReadKey(); db.SaveNewCandy(selectedCandyType.Key, "CandyType"); // Candy Names // var candyNames = db.GetCandyNames(); var newCandyMenuNames = new View() .AddMenuText("What is the name of the candy?") .AddMenuOptions(candyNames); Console.Write(newCandyMenuNames.GetFullMenu()); var selectedCandyName = Console.ReadKey(); db.SaveNewCandy(selectedCandyName.Key, "CandyName"); // Candy Manufacturers // var candyManufacturers = db.GetCandyManufacturers(); var newCandyMenuManufacturers = new View() .AddMenuText("Who made the candy?") .AddMenuOptions(candyManufacturers); Console.Write(newCandyMenuManufacturers.GetFullMenu()); var selectedCandyManufacturer = Console.ReadKey(); db.SaveNewCandy(selectedCandyManufacturer.Key, "CandyManuf"); // Candy Flavors // var candyFlavors = db.GetFlavorCategories(); var newCandyMenuFlavor = new View() .AddMenuText("What flavor is the candy?") .AddMenuOptions(candyFlavors); Console.Write(newCandyMenuFlavor.GetFullMenu()); var selectedCandyFlavor = Console.ReadKey(); db.SaveNewCandy(selectedCandyFlavor.Key, "CandyFlavor"); // Candy Acquired Date // var newCandyMenuDateAcquired = new View() .AddMenuText("When did you acquire the candy? MM/DD/YYYY"); Console.Write(newCandyMenuDateAcquired.GetFullMenu()); var dateOfAcquisition = Console.ReadLine(); db.SetCandyAcquisitionDate(dateOfAcquisition); db.PersistNewCandyObject(); }
internal static void EatSomeCandy() { var db = new CandyStorage(); var currentCandyInventory = db.ReturnCandyInventory(); if (currentCandyInventory.Count < 1) { var eatCandy = new View() .AddMenuText("You have no candy"); Console.Write(eatCandy.GetFullMenu()); Console.ReadKey(); } else { var viewCandy = new View() .AddMenuText("Here is your candy inventory:"); Console.Write(viewCandy.GetFullMenu()); for (int i = 0; i < currentCandyInventory.Count; i++) { Console.WriteLine(""); Console.WriteLine(" Candy Name: " + currentCandyInventory[i].Name); Console.WriteLine(" Candy Type: " + currentCandyInventory[i].CandyType); Console.WriteLine(" Candy Manufacturer: " + currentCandyInventory[i].Manufacturer); Console.WriteLine(" Candy Flavor: " + currentCandyInventory[i].FlavorCategory); Console.WriteLine("Candy Date Received: " + currentCandyInventory[i].DateReceived); } Console.WriteLine(""); Console.WriteLine("Press any key to continue"); Console.ReadKey(); } }
public static void PickUser(CandyStorage db) { var users = db.allTheUsers(); Console.WriteLine("Here are your users"); foreach (var user in users) { Console.WriteLine($"{user.userName}"); } Console.ReadLine(); Console.WriteLine("Which user would you like to use?:"); var userChoice = Console.ReadLine(); var userIfound = users.Where(user => user.userName == userChoice).Single(); Console.WriteLine($"Here are the candies for {userChoice}: "); var candies = db.getOwnersCandy(userIfound.Id); foreach (var candy in candies) { Console.WriteLine($"{candy.Name}"); } Console.ReadLine(); var userInput = MainMenu(); var exit = false; exit = TakeActions(db, userInput); }
private static bool TakeActions(CandyStorage db, ConsoleKeyInfo userInput, List <CandyStorage> candyOwners) { Console.Write(Environment.NewLine); if (userInput.Key == ConsoleKey.Escape) { return(true); } var selection = userInput.KeyChar.ToString(); switch (selection) { case "1": AddNewCandy(db, candyOwners); break; case "2": EatCandyByFlavor(db, candyOwners); break; case "3": EatCandy(db, candyOwners); break; case "4": TradeCandy(db, candyOwners); break; default: return(true); } return(true); }
internal static void RemoveCandy(Candy candy, CandyStorage db, List <CandyStorage> candyOwners) { var theCandy = db.Candies; theCandy.Remove(candy); Console.WriteLine(); Console.WriteLine("You have these candies left:"); foreach (var c in theCandy) { Console.WriteLine($"{c.Name} acquired {c.Date}."); } Console.WriteLine(); Console.WriteLine("Hit enter to continue."); Console.ReadKey(); var exit = false; while (!exit) { var userInput = MainMenu(); exit = TakeActions(db, userInput, candyOwners); } }
private static void EatCandy(CandyStorage db) { var list = db.allTheDefaultCandies().OrderBy(x => x.DateReceived); var defaultCandyList = db.allTheDefaultCandies().OrderBy(y => y.DateReceived); Console.WriteLine("Here are your candies"); foreach (var defaultCandy in defaultCandyList) { Console.WriteLine($"{defaultCandy.Name} : {defaultCandy.Manufacturer} : {defaultCandy.Flavor} : {defaultCandy.DateReceived}"); } foreach (var candy in list) { Console.WriteLine($"{candy.Name} : {candy.Manufacturer} : {candy.Flavor} : {candy.DateReceived}"); } var candyList = db.allTheDefaultCandies(); Console.WriteLine("Would you like to eat a piece of candy?"); var eatingCandyInput = Console.ReadLine(); var filterCandies = candyList.Where(candy => candy.Name == eatingCandyInput).ToList(); var eatingCandy = filterCandies.Single(); candyList.Remove(eatingCandy); var userInput = MainMenu(); var exit = false; exit = TakeActions(db, userInput); }
internal static void AddNewCandy(CandyStorage db) { Console.WriteLine($"Candy Name:"); var candyName = Console.ReadLine(); Console.WriteLine($"Manufacturer:"); var candyManufacturer = Console.ReadLine(); Console.WriteLine($"Flavor:"); var flavorCrap = Console.ReadLine(); Console.WriteLine($"Date: {DateTime.Now}"); var candyDateReceived = DateTime.Now.ToString(); var newCandy = new Candy { Name = candyName, Manufacturer = candyManufacturer, Flavor = flavorCrap, DateReceived = candyDateReceived, }; db.SaveNewCandy(newCandy); Console.WriteLine("Your Candy: "); Console.WriteLine($"{newCandy.Name} : {newCandy.Manufacturer} : {newCandy.Flavor} : {newCandy.DateReceived}"); Console.ReadLine(); var userInput = MainMenu(); var exit = false; exit = TakeActions(db, userInput); }
private static void EatCandy(CandyStorage db) { Console.WriteLine("Here is a list to choose candy to eat :"); db.PrintList(); Console.WriteLine("Choose just ONE candy by typing it in and hitting enter to EAT!"); db.FindCandy(); }
private static void NewTrade(CandyStorage db) { Console.WriteLine("Enter your name and hit Enter"); myName = Console.ReadLine(); Console.WriteLine("Enter your id and hit Enter"); myId = int.Parse(Console.ReadLine()); }
private static void TradeCandy(CandyStorage db) { Console.WriteLine("Here are candy owners you can trade with."); // db.PrintOwnersList(); db.MatchCandyId(); Console.WriteLine("Hit Enter to go back to the menu!"); }
static List <Candy> filterCandy(string candyFlavor, CandyStorage db) { var candyList = db.ShowList(); var filteredCandyList = candyList.FindAll(candy => candy.Flavor == candyFlavor); return(filteredCandyList); }
private static bool TakeActions(CandyStorage db, ConsoleKeyInfo userInput, List <string> FlavorList, Users users) { Console.Write(Environment.NewLine); if (userInput.Key == ConsoleKey.Escape) { return(true); } var selection = userInput.KeyChar.ToString(); switch (selection) { case "1": AddNewCandy(db, FlavorList); return(false); case "2": EatCandy(db); return(false); case "3": EatRandomCandy(db, FlavorList); return(false); case "4": TradeCandy(users); return(false); case "5": ListCandy(db); return(false); default: return(false); } }
private static void ListOfCandy(CandyStorage db) { Console.WriteLine("Here is your list of current candies in inventory"); foreach (Candy candy in db._myCandy) { Console.WriteLine($"Candy : {candy.Name} Flavor : {candy.Flavor}"); } Console.ReadLine(); }
private static void ListCandy(CandyStorage db) { foreach (var candy in db.ShowList()) { Console.Write($"\t{candy.Name}\n"); } Console.WriteLine("\nPress any key to return to the main menu"); Console.ReadKey(); }
internal static CandyStorage SetupNewApp() { Console.Title = "Cross Confectioneries Incorporated"; var db = new CandyStorage(); Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; return(db); }
internal static void DisplayCandyNames(CandyStorage db) { var candyName = db.GetNames(); var candyNameMenu = new View() .AddMenuText("Select from the following:") .AddMenuOptions(candyName); Console.Write(candyNameMenu.GetFullMenu()); Console.ReadKey(); }
internal static CandyStorage SetupNewApp(string ownerName) { Console.Title = "Cross Confectioneries Incorporated"; Console.BackgroundColor = ConsoleColor.DarkMagenta; Console.ForegroundColor = ConsoleColor.Cyan; var db = new CandyStorage(ownerName); return(db); }
internal static void AddNewCandy(CandyStorage db) { var newCandy = new Candy { Name = "Whatchamacallit" }; var savedCandy = db.SaveNewCandy(newCandy); Console.WriteLine($"Now you own the candy {savedCandy.Name}"); }
private static void EatCandy(CandyStorage db, List <CandyStorage> candyOwners) { var theCandy = db.Candies; List <string> candyNames = new List <string>(); var candyMenu = new View(); foreach (var candy in theCandy) { if (candyNames.Contains(candy.Name) == false) { candyNames.Add(candy.Name); } } foreach (var name in candyNames) { candyMenu.AddMenuOption(name); } Console.Write(candyMenu.GetFullMenu()); Console.WriteLine(); Console.WriteLine("Please select the candy you would like to eat."); var flavorMenuInput = Console.ReadKey(); var chosenNameNumber = int.Parse(flavorMenuInput.KeyChar.ToString()); var filteredCandy = theCandy.Where(c => c.Name.Contains(candyNames[chosenNameNumber - 1])) .ToList(); var oldestCandy = filteredCandy.OrderBy(c => c.Date).First(); RemoveCandy(oldestCandy, db, candyOwners); //Console.WriteLine(); //Console.WriteLine("You have these candies left:"); //foreach (var candy in theCandy) //{ // Console.WriteLine($"{candy.Name} acquired {candy.Date}."); //} //Console.WriteLine(); //Console.WriteLine("Hit enter to continue."); //Console.ReadKey(); //var exit = false; //while (!exit) //{ // var userInput = MainMenu(); // exit = TakeActions(db, userInput, candyOwners); //} }
internal static ConsoleKeyInfo MainMenu(CandyStorage db) { View mainMenu = new View() .AddMenuOption("Did you just get some new candy? Add it here.") .AddMenuOption("Do you want to eat some candy? Take it here.") .AddMenuText("Press 0 to exit."); Console.Write(mainMenu.GetFullMenu()); var userOption = Console.ReadKey(); return(userOption); }
internal static ConsoleKeyInfo MainMenu(CandyStorage db) { View mainMenu = new View() .AddMenuOption("Add new candy") .AddMenuOption("Eat candy") .AddMenuText("Press 0 to exit."); Console.Write(mainMenu.GetFullMenu()); var userOption = Console.ReadKey(); return(userOption); }
internal static void AddNewCandy(CandyStorage db) { var candyTypes = db.GetCandyTypes(); var newCandyMenu = new View() .AddMenuText("What type of candy did you get?") .AddMenuOptions(candyTypes); Console.Write(newCandyMenu.GetFullMenu()); var selectedCandyType = Console.ReadKey(); db.SaveNewCandy(selectedCandyType.Key); }