public static void CollectInput(Farm farm) { Console.WriteLine(@"1. Sesame"); Console.WriteLine(@"2. Sunflower"); Console.WriteLine(@"3. Wildflower"); Console.WriteLine(); Console.WriteLine("Choose seed to Purchase"); Console.Write("> "); int choice = 0; while (choice == 0) { try { choice = Int32.Parse(Console.ReadLine()); switch (choice) { case 1: ChooseFacility.CollectInput(farm, farm.PlowedFields, new Sesame()); Console.WriteLine("Chickens do not graze, you fool!"); break; case 2: ChooseFacility.CollectInput(farm, farm.NaturalFields, farm.PlowedFields, new Sunflower()); break; case 3: ChooseFacility.CollectInput(farm, farm.NaturalFields, new WildFlower()); Console.WriteLine("Ducks do not graze, you fool!"); break; default: Console.WriteLine("That was an invalid selection. Hit enter to continue to the main menu"); Console.Read(); break; } } catch (FormatException) { Console.WriteLine("Please input a valid number from the above menu."); Console.Write(" >"); } } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Sunflower"); Console.WriteLine("2. Wildflower"); Console.WriteLine("3. Sesame"); Console.WriteLine(); Console.WriteLine("What are you buying today?"); Console.Write("> "); string choice = Console.ReadLine(); //if user selection is valid then they return to main menu after animal is added to the facility //if the user makes and invalid selection they can return to the menu to select a facility or return to the main menu try { bool stayOnMenu = true; switch (Int32.Parse(choice)) { case 1: do { //either plowed or natural field var plantList = farm.PlowedFields.Concat(farm.NaturalFields).ToList(); stayOnMenu = ChooseFacility.CollectInput(farm, new Sunflower(), plantList); }while (stayOnMenu); break; case 2: do { //natural field stayOnMenu = ChooseFacility.CollectInput(farm, new Wildflower(), farm.NaturalFields); }while (stayOnMenu); break; case 3: do { //plowed field stayOnMenu = ChooseFacility.CollectInput(farm, new Sesame(), farm.PlowedFields); }while (stayOnMenu); break; default: break; } } catch (Exception) { } }
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("> "); int choice = 0; while (choice == 0) { try { choice = Int32.Parse(Console.ReadLine()); Console.Clear(); switch (choice) { case 1: ChooseFacility.CollectInput(farm, farm.ChickenHouses, new Chicken()); break; case 2: ChooseFacility.CollectInput(farm, farm.GrazingFields, new Cow()); break; case 3: ChooseFacility.CollectInput(farm, farm.DuckHouses, new Duck()); break; case 4: ChooseFacility.CollectInput(farm, farm.GrazingFields, new Goat()); break; case 5: ChooseFacility.CollectInput(farm, farm.GrazingFields, new Ostrich()); break; case 6: ChooseFacility.CollectInput(farm, farm.GrazingFields, new Pig()); break; case 7: ChooseFacility.CollectInput(farm, farm.GrazingFields, new Sheep()); break; default: Console.WriteLine("Invalid selection. Click enter to return to the main menu."); Console.Read(); break; } } catch (FormatException) { Console.WriteLine("Please input a number from above!"); Console.Write("> "); } } }
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("> "); string choice = Console.ReadLine(); //if user selection is valid then they return to main menu after animal is added to the facility //if the user makes and invalid selection they can return to the menu to select a facility or return to the main menu try { bool stayOnMenu = true; switch (Int32.Parse(choice)) { case 1: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Chicken(), farm.ChickenHouses); }while (stayOnMenu); break; case 2: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Cow(), farm.GrazingFields); }while (stayOnMenu); break; case 3: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Duck(), farm.DuckHouses); }while (stayOnMenu); break; case 4: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Goat(), farm.GrazingFields); }while (stayOnMenu); break; case 5: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Ostrich(), farm.GrazingFields); }while (stayOnMenu); break; case 6: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Pig(), farm.GrazingFields); }while (stayOnMenu); break; case 7: do { stayOnMenu = ChooseFacility.CollectInput(farm, new Sheep(), farm.GrazingFields); }while (stayOnMenu); break; default: break; } } catch (Exception) { } }