public static void CollectInput(Farm farm, ICompost plant) { var fullNaturalFields = new List <int>(); // Make a list of available fields Console.Clear(); for (int i = 0; i < farm.NaturalFields.Count; i++) { if (farm.NaturalFields[i].PlantCount < farm.NaturalFields[i].Capacity) { // Calculate Plant Count By Type var typeList = (from p in farm.NaturalFields[i].PlantsList group p by p.Type into g let count = g.Count() select new { Value = g.Key, Count = count }); // Print Message Console.WriteLine($"{i + 1}. Natural Field {farm.NaturalFields[i].id} has {farm.NaturalFields[i].PlantCount} plant rows"); if (farm.NaturalFields[i].PlantCount > 0) { foreach (var type in typeList) { Console.WriteLine($" {type.Value}: {type.Count}"); } } } else { fullNaturalFields.Add(i); }; } if (fullNaturalFields.Count == farm.NaturalFields.Count) { Console.WriteLine("Please create a new facility"); CreateFacility.CollectInput(farm); } else { Console.WriteLine($"Plant the seeds where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); if (farm.NaturalFields[choice - 1].PlantCount < farm.NaturalFields[choice - 1].Capacity) { farm.NaturalFields[choice - 1].AddResource(plant); } else { Console.WriteLine("Please select an available facility option"); CreateFacility.CollectInput(farm); } Console.WriteLine(); // How can I output the type of seeds chosen here? /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Natural field"); Console.WriteLine("4. Duck House"); Console.WriteLine("5. Chicken House"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); try { switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); break; case 2: farm.AddPlowingField(new PlowingField()); break; case 3: farm.AddNaturalField(new NaturalField()); break; case 4: farm.AddDuckHouse(new DuckHouse()); break; case 5: farm.AddChickenHouse(new ChickenHouse()); break; default: break; } } catch (FormatException) { Console.Clear(); Console.WriteLine(); Console.WriteLine(@" +-++-++-++-++-++-++-++-++-++-++-++-++-+ \|/ (__) |T||r||e||s||t||l||e||b||r||i||d||g||e| (oo)-----/` +-++-++-++-++-++-++-++-++-++-++-++-++-+ Moooooops- (__) || |F||a||r||m||s| That didn't ||--w|| \|/ +-++-++-++-++-+ work \|/ "); Console.WriteLine(); Console.WriteLine("Please select an available facility option"); CreateFacility.CollectInput(farm); } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Natural field"); Console.WriteLine("4. Chicken house"); Console.WriteLine("5. Duck house"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); try { int choice = Int32.Parse(Console.ReadLine()); switch (choice) { case 1: farm.AddGrazingField(new GrazingField()); break; case 2: farm.AddPlowedField(new PlowedField()); break; case 3: farm.AddNaturalField(new NaturalField()); break; case 4: farm.AddChickenHouse(new ChickenHouse()); break; case 5: farm.AddDuckHouse(new DuckHouse()); break; default: Console.WriteLine($"Invalid option: {choice}"); Console.WriteLine("Press any key to go back to the menu."); Console.ReadLine(); Console.Clear(); CreateFacility.CollectInput(farm); break; } } catch (FormatException) { Console.WriteLine($"Invalid option"); Console.WriteLine("Press any key to go back to the menu."); Console.ReadLine(); Console.Clear(); CreateFacility.CollectInput(farm); } }
public static void CollectInput(Farm farm, IHousable animal) { var fullChickenHouses = new List <int>(); // Make a list of available chicken houses Console.Clear(); for (int i = 0; i < farm.ChickenHouses.Count; i++) { if (farm.ChickenHouses[i].AnimalCount < farm.ChickenHouses[i].Capacity) { // Print Message Console.WriteLine($"{i + 1}. Chicken House {farm.ChickenHouses[i].id} has {farm.ChickenHouses[i].AnimalCount} chickens"); } else { fullChickenHouses.Add(i); }; if (fullChickenHouses.Count == farm.ChickenHouses.Count) { Console.WriteLine("Please create a new facility"); CreateFacility.CollectInput(farm); } else { Console.WriteLine($"Place the animal where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); if (farm.ChickenHouses[choice - 1].AnimalCount < farm.ChickenHouses[choice - 1].Capacity) { farm.ChickenHouses[choice - 1].AddResource(animal); } else { // Console.WriteLine("This chicken house is full"); Console.WriteLine("Please select an available facility option"); CreateFacility.CollectInput(farm); } Console.WriteLine(); } } // How can I output the type of animal chosen here? /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Sesame"); Console.WriteLine("2. Sunflower"); Console.WriteLine("3. Wildflower"); Console.WriteLine(); Console.WriteLine("What are you buying today?"); Console.Write("> "); try { int choice = Int32.Parse(Console.ReadLine()); Console.Clear(); switch (choice) { case 1: if (farm.PlowedFields.Count != 0) { ChoosePlowedField.CollectInput(farm, new Sesame()); } else { Console.WriteLine("You don't have any facilities for this plant!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 2: Console.Clear(); Console.WriteLine("1. Seeds"); Console.WriteLine("2. Compost"); Console.WriteLine(); Console.WriteLine("What resource do you want from Sunflowers?"); Console.Write("> "); int resourceChoice = Int32.Parse(Console.ReadLine()); if (resourceChoice == 1) { if (farm.PlowedFields.Count != 0) { ChoosePlowedField.CollectInput(farm, new Sunflower()); } else { Console.WriteLine("You don't have any facilities for this plant!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } } else if (resourceChoice == 2) { if (farm.NaturalFields.Count != 0) { ChooseNaturalField.CollectInput(farm, new Sunflower()); } else { Console.WriteLine("You don't have any facilities for this plant!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } } else { Console.WriteLine($"Invalid option: {resourceChoice}"); Console.WriteLine("Press any key to go back to main menu."); Console.ReadLine(); } break; case 3: if (farm.NaturalFields.Count != 0) { ChooseNaturalField.CollectInput(farm, new Wildflower()); } else { Console.WriteLine("You don't have any facilities for this plant!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; default: Console.WriteLine($"Invalid option: {choice}"); Console.WriteLine("Press any key to go back to the menu."); Console.ReadLine(); Console.Clear(); CollectInput(farm); break; } } catch (FormatException) { Console.WriteLine($"Invalid option"); Console.WriteLine("Press any key to go back to the menu."); Console.ReadLine(); Console.Clear(); CollectInput(farm); } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Sesame"); Console.WriteLine("2. Wildflower"); Console.WriteLine("3. Sunflower"); Console.WriteLine(); Console.WriteLine("What are you buying today?"); Console.Write("> "); string choice = Console.ReadLine(); try { switch (Int32.Parse(choice)) { case 1: if (farm.PlowingFields.Count >= 1) { ChoosePlowingField.CollectInput(farm, new Sesame()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a field for this flower yet."); CreateFacility.CollectInput(farm); } break; case 2: if (farm.NaturalFields.Count >= 1) { ChooseNaturalField.CollectInput(farm, new Wildflower()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a field for this flower yet."); CreateFacility.CollectInput(farm); } break; case 3: { Console.Clear(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("1. Plowed Field"); Console.WriteLine("2. Natural Field"); Console.WriteLine(); Console.WriteLine("Choose What type of Field to plant your Sunflowers in:"); Console.Write("> "); string fieldType = Console.ReadLine(); switch (Int32.Parse(fieldType)) { case 1: if (farm.PlowingFields.Count >= 1) { ChoosePlowingField.CollectInput(farm, new Sunflower()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a field for this flower yet."); CreateFacility.CollectInput(farm); } break; case 2: if (farm.NaturalFields.Count >= 1) { ChooseNaturalField.CollectInput(farm, new Sunflower()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a field for this flower yet."); CreateFacility.CollectInput(farm); } break; default: break; } break; } default: break; } } catch (FormatException) { Console.Clear(); Console.WriteLine(); Console.WriteLine(@" .-'`/\ // /' /\`\ Shucks that didn't work ('//.-'/`-.; \ \ / /-. __.__.___..__._.___.\\ \\----,_ .:{@&#,&#@&,@&#&&,#&@#&@&\\` \-. .-'-. .:{@#@,#@&#,@#&&#,@&#&@&,&@#&&\\, -._,- \ .{#@#&@#@#&#&@&#@#@&#,@#@#&@&&#@#\ \// = \`=\__ `{#@,@#&@&,@&#@,#@&#@#&@#&@,&#@,#/\/ =`-. -_=__ `:{@#&@&#@&#@&#@,#&&#@&,@#/.' / / /.-', / `:{@#&,#&@#,@&#&@&,@&#/.-// //-'-_= ,/ `~`~~`~~~`~`~`~~`~( / , /__,___.- Sorry for the corny joke... \ \\/ `\\\' "); Console.WriteLine(); Console.WriteLine("Please select an available seed option"); PurchaseSeeds.CollectInput(farm); } }
public static void Run() { Console.ForegroundColor = ConsoleColor.White; Console.BackgroundColor = ConsoleColor.DarkBlue; Farm Trestlebridge = new Farm(); while (true) { List <string> menuOptions = new List <string>() { "Create Facility" }; if (Trestlebridge.Facilities.Count > 0) { menuOptions.Add("Purchase Resources"); menuOptions.Add("Process Resources"); } menuOptions.Add("Display Farm Status Report"); int response = StandardMessages.ShowMenu(menuOptions, "Choose a FARMS option...", "Quit Program."); if (response == 0) { // Quit program. Console.WriteLine("Today is a great day for farming"); Trestlebridge.Save(); return; } switch (menuOptions[response - 1]) { case "Create Facility": CreateFacility.CollectInput(Trestlebridge); break; case "Purchase Resources": PurchaseResource.CollectInput(Trestlebridge); break; case "Display Farm Status Report": FarmReport(Trestlebridge); break; case "Process Resources": ProcessResources.CollectInput(Trestlebridge); break; default: break; } ; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Natural field"); Console.WriteLine("4. Chicken Coop"); Console.WriteLine("5. Duck House"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); try { if (int.Parse(input) <= 5 && int.Parse(input) >= 1) { switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); break; case 2: farm.AddPlowedField(new PlowedField()); break; case 3: farm.AddNaturalField(new NaturalField()); break; case 4: farm.AddChickenCoop(new ChickenCoop()); break; case 5: farm.AddDuckHouse(new DuckHouse()); break; default: Console.WriteLine("Invalid option. Redirecting to main menu."); Thread.Sleep(2000); break; } } else { Console.WriteLine("Invalid option. Please try again."); Thread.Sleep(2000); DisplayBanner(); CreateFacility.CollectInput(farm); } } catch (FormatException) { Console.WriteLine("Invalid option. Please try again."); Thread.Sleep(2000); DisplayBanner(); CreateFacility.CollectInput(farm); } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Chicken"); Console.WriteLine("2. Cow"); Console.WriteLine("3. Duck"); Console.WriteLine("4. Goat"); Console.WriteLine("5. Ostrich"); Console.WriteLine("6. Pig"); Console.WriteLine("7. Sheep"); Console.WriteLine(); Console.WriteLine("What are you buying today?"); Console.Write("> "); try { int choice = Int32.Parse(Console.ReadLine()); Console.Clear(); switch (choice) { case 1: if (farm.ChickenHouses.Count != 0) { ChooseChickenHouse.CollectInput(farm, new Chicken()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 2: if (farm.GrazingFields.Count != 0) { ChooseGrazingField.CollectInput(farm, new Cow()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 3: if (farm.DuckHouses.Count != 0) { ChooseDuckHouse.CollectInput(farm, new Duck()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 4: if (farm.GrazingFields.Count != 0) { ChooseGrazingField.CollectInput(farm, new Goat()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 5: if (farm.GrazingFields.Count != 0) { ChooseGrazingField.CollectInput(farm, new Ostrich()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 6: if (farm.GrazingFields.Count != 0) { ChooseGrazingField.CollectInput(farm, new Pig()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; case 7: if (farm.GrazingFields.Count != 0) { ChooseGrazingField.CollectInput(farm, new Sheep()); } else { Console.WriteLine("You don't have any facilities for this animal!"); Console.WriteLine("Press any key to go to the Create Facility menu"); Console.ReadLine(); CreateFacility.CollectInput(farm); } break; default: Console.WriteLine($"Invalid option: {choice}"); Console.WriteLine("Press any key to go back to the menu."); Console.ReadLine(); Console.Clear(); CollectInput(farm); break; } } catch (FormatException) { Console.WriteLine($"Invalid option"); Console.WriteLine("Press any key to go back to the menu."); Console.ReadLine(); Console.Clear(); CollectInput(farm); } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Cow"); Console.WriteLine("2. Ostrich"); Console.WriteLine("3. Goat"); Console.WriteLine("4. Sheep"); Console.WriteLine("5. Pig"); Console.WriteLine("6. Chicken"); Console.WriteLine("7. Duck"); Console.WriteLine(); Console.WriteLine("What are you buying today?"); Console.Write("> "); string choice = Console.ReadLine(); try { switch (Int32.Parse(choice)) { case 1: if (farm.GrazingFields.Count >= 1) { ChooseGrazingField.CollectInput(farm, new Cow()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; case 2: if (farm.GrazingFields.Count >= 1) { ChooseGrazingField.CollectInput(farm, new Ostrich()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; case 3: if (farm.GrazingFields.Count >= 1) { ChooseGrazingField.CollectInput(farm, new Goat()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; case 4: if (farm.GrazingFields.Count >= 1) { ChooseGrazingField.CollectInput(farm, new Sheep()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; case 5: if (farm.GrazingFields.Count >= 1) { ChooseGrazingField.CollectInput(farm, new Pig()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; case 6: if (farm.ChickenHouses.Count >= 1) { ChooseChickenHouse.CollectInput(farm, new Chicken()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; case 7: if (farm.DuckHouses.Count >= 1) { ChooseDuckHouse.CollectInput(farm, new Duck()); } else { Console.Clear(); System.Console.WriteLine("You haven't created a facility for this animal yet."); CreateFacility.CollectInput(farm); } break; default: break; } } catch (FormatException) { Console.Clear(); Console.WriteLine(); Console.WriteLine(@" _ _ _ _ ____ _ _ / |__| |--| [__] |--|. _ -=(') ;; // // : '.---.__ | --_-_)__) `.____,' \ \ ___\ \ ( \ \ - There's been an Ost-glitch / "); Console.WriteLine(); Console.WriteLine("Please select an available stock option"); PurchaseStock.CollectInput(farm); } }