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(); }
static void Main(string[] args) { var FlavorList = new List <string>(); FlavorList.Add("sour"); FlavorList.Add("sweet"); FlavorList.Add("bitter"); FlavorList.Add("savory"); var dylan = new CandyStorage("Dylan"); dylan.SaveNewCandy(new Candy("Snickers", "Mars", "sweet", new DateTime(2019, 12, 23))); dylan.SaveNewCandy(new Candy("Butterfinger", "Mars", "bitter", new DateTime(2019, 12, 23))); dylan.SaveNewCandy(new Candy("Twix", "Mars", "sweet", new DateTime(2019, 12, 23))); var austin = new CandyStorage("Austin"); austin.SaveNewCandy(new Candy("Snickers", "Mars", "sweet", new DateTime(2019, 12, 23))); austin.SaveNewCandy(new Candy("Butterfinger", "Mars", "bitter", new DateTime(2019, 12, 23))); austin.SaveNewCandy(new Candy("Twix", "Mars", "sweet", new DateTime(2019, 12, 23))); var jonathan = new CandyStorage("Jonathan"); jonathan.SaveNewCandy(new Candy("Snickers", "Mars", "sweet", new DateTime(2019, 12, 23))); jonathan.SaveNewCandy(new Candy("Butterfinger", "Mars", "bitter", new DateTime(2019, 12, 23))); jonathan.SaveNewCandy(new Candy("Twix", "Mars", "sweet", new DateTime(2019, 12, 23))); var users = new Users(); users.AddOwner(dylan); users.AddOwner(austin); users.AddOwner(jonathan); Console.WriteLine("Enter User Name"); var db = SetupNewApp(Console.ReadLine()); users.AddOwner(db); db.SaveNewCandy(new Candy("Snickers", "Mars", "sweet", new DateTime(2019, 12, 23))); db.SaveNewCandy(new Candy("Butterfinger", "Mars", "bitter", new DateTime(2019, 12, 23))); db.SaveNewCandy(new Candy("Twix", "Mars", "sweet", new DateTime(2019, 12, 23))); var exit = false; while (!exit) { var userInput = MainMenu(); exit = TakeActions(db, userInput, FlavorList, users); } }
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); }
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); }
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(); }
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}"); }
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); }
internal void tradeCandy(string tradedCandy, string newCandy, CandyStorage ownerName) { var ownerCandy = _myCandy.Find(candy => candy.Name == tradedCandy); var traderCandy = ownerName._myCandy.Find(candy => candy.Name == newCandy); //Adds new candies to each owners' lists ownerName.SaveNewCandy(ownerCandy); _myCandy.Add(traderCandy); //Removes traded candies from owners' lists ownerName.RemoveCandyFromInventory(traderCandy); _myCandy.Remove(ownerCandy); }