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("> "); string input = Console.ReadLine(); // functions to create facilities with completion message switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("New Grazing Field Added"); Console.WriteLine("Press Any Key To Continue"); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("New Plowed Field Added"); Console.WriteLine("Press Any Key To Continue"); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("New Natural Field Added"); Console.WriteLine("Press Any Key To Continue"); Console.ReadLine(); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("You have a new chicken house!"); Console.WriteLine("Hit any key to continue"); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("You have a new duck house!"); Console.WriteLine("Hit any key to continue"); Console.ReadLine(); 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(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); 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; default: break; } }
public static void CollectInput(Farm farm) { // print out the options of locations 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("> "); // reading user selection string input = Console.ReadLine(); // conditional that takes selection and prints option submenu switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); //prints confirmation of grazing field creation. Console.WriteLine("Grazing Field created."); Console.WriteLine("Hit Return Key to return to main menu."); Console.ReadLine(); break; default: break; case 2: farm.AddPlowedField(new PlowedField()); //prints confirmation of plowed field creation. Console.WriteLine("Plowed Field created."); Console.WriteLine("Press return key to go back to main menu."); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); //prints confirmation of natural field creation. Console.WriteLine("Natural Field created."); Console.WriteLine("Press return key to go back to main menu."); Console.ReadLine(); break; case 4: farm.AddChickenHouse(new ChickenHouse()); //prints confirmation of chicken house creation. Console.WriteLine("Press return key to go back to main menu."); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); //prints confirmation of duck house creation. Console.WriteLine("Press return key to go back to main menu."); Console.ReadLine(); 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 House"); Console.WriteLine("5. Duck 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()); Console.WriteLine("You added a new grazing field!"); Console.WriteLine("Press any key to return to main menu"); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("You added a new plowed field!"); Console.WriteLine("Press any key to return to main menu"); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("You added a new natural field!"); Console.WriteLine("Press any key to return to main menu"); Console.ReadLine(); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("You added a new chicken house!"); Console.WriteLine("Press any key to return to main menu"); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("You added a new duck house!"); Console.WriteLine("Press any key to return to main menu"); Console.ReadLine(); break; default: break; } } catch (Exception) { } }
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("> "); string input = Console.ReadLine(); //menu for creating facilities //changed it from the code that was given //now it looks and functions just like the main menu // changed the confirmation message show which facility you have added // added a timer on the confirmation message so you can see the message if (input == "1") { farm.AddGrazingField(new GrazingField()); Console.WriteLine("Grazing Field has been added"); Thread.Sleep(2000); } else if (input == "2") { farm.AddPlowedField(new PlowedField()); Console.WriteLine("Plowed Field has been added"); Thread.Sleep(2000); } else if (input == "3") { farm.AddNaturalField(new NaturalField()); Console.WriteLine("Natural Field has been added"); Thread.Sleep(2000); } else if (input == "4") { farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("Chicken House has been added"); Thread.Sleep(2000); } else if (input == "5") { farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("Duck House has been added"); Thread.Sleep(2000); } //error handling else { Console.WriteLine($"Invalid input: {input}"); Console.WriteLine("Returning to the main menu"); Thread.Sleep(2000); } }
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) { 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("> "); //this is where we are stating the selections and what/where they will be going to string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("Grazing Field Created!!!!!"); Console.WriteLine("Press Return to go back to the Main Menu"); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("Plowed field created."); Console.WriteLine("Press Return to go back to the Main Menu"); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("Natural field created."); Console.WriteLine("Press Return to go back to the Main Menu"); Console.ReadLine(); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("Chicken House(coop) built!!!"); Console.WriteLine("Press Return to go back to the Main Menu"); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("Duck House built quack quack!!!"); Console.WriteLine("Press Return to go back to the Main Menu"); Console.ReadLine(); break; default: break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Chicken house"); Console.WriteLine("4. Natural Field"); Console.WriteLine("5. Duck House"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: Console.WriteLine("generating grazing field, please press enter to continue"); Console.ReadLine(); farm.AddGrazingField(new GrazingField()); break; case 2: Console.WriteLine("Generating plowed field, please press enter to continue"); Console.ReadLine(); farm.AddPlowedField(new PlowedField()); break; case 5: Console.WriteLine("generating duck house, please press enter to continue"); Console.ReadLine(); farm.AddDuckHouse(new DuckHouse()); break; case 3: Console.WriteLine("Creating chicken house, please press enter to continue"); Console.ReadLine(); farm.AddChickenHouse(new ChickenHouse()); break; case 4: Console.WriteLine("generating natural field, please press enter to continue"); Console.ReadLine(); farm.AddNaturalField(new NaturalField()); 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 House"); Console.WriteLine("5. Duck 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.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: break; } } catch (FormatException) { Console.WriteLine(); Console.WriteLine("Invalid input! Press any key to return home"); Console.ReadLine(); } catch (ArgumentOutOfRangeException) { Console.WriteLine(); Console.WriteLine("Invalid input! Press any key to return home"); Console.ReadLine(); } }
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("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("You have created a grazing field!"); Console.WriteLine("Hit Enter again to return to the main menu"); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("You have created a plowed field!"); Console.WriteLine("Hit Enter again to return to the main menu"); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("You have created a natural field!"); Console.WriteLine("Hit Enter again to return to the main menu"); Console.ReadLine(); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("You have created a chicken house!"); Console.WriteLine("Hit Enter again to return to the main menu"); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("You have created a duck house!"); Console.WriteLine("Hit Enter again to return to the main menu"); Console.ReadLine(); break; default: break; } }
public static void CollectInput(Farm farm) { try { 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("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { // Added case for all facilities 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("Please enter a valid option."); Thread.Sleep(1000); Utils.Clear(); CollectInput(farm); break; } } catch { Console.WriteLine("Please enter a valid option."); Thread.Sleep(1000); Utils.Clear(); 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("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); // foreach (var g in farm.GrazingFields) { // Console.WriteLine (g); // } Console.WriteLine("Congratulations, new grazing field created!!!"); Thread.Sleep(TimeSpan.FromSeconds(2.5)); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("Congratulations, new plowed field created!!!"); Thread.Sleep(TimeSpan.FromSeconds(2.5)); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("Congratulations, new natural field created!!!"); Thread.Sleep(TimeSpan.FromSeconds(2.5)); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("Congratulations, new chicken house created!!!"); Thread.Sleep(TimeSpan.FromSeconds(2.5)); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("Congratulations, new duck house created!!!"); Thread.Sleep(TimeSpan.FromSeconds(2.5)); break; default: break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Duck House"); Console.WriteLine("4. Chicken Coop"); Console.WriteLine("5. Natural Field"); // Add in other facilities Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("You created a grazing field! Good Job!"); Thread.Sleep(1000); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("You plowed that field! Great job buddy!"); Thread.Sleep(1000); break; case 3: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("You created a Duck House! Good Job!"); Thread.Sleep(1000); break; case 4: farm.AddChickenCoop(new ChickenCoop()); Console.WriteLine("You built a chicken coop! You're so strong! WOW WOW WOW"); Thread.Sleep(1000); break; case 5: farm.AddNaturalField(new NaturalField()); Console.WriteLine("You built a Natural Field! You're so strong! WOW WOW WOW"); Thread.Sleep(1000); break; default: break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Chicken House"); Console.WriteLine("3. Duck House"); Console.WriteLine("4. Plowed field"); Console.WriteLine("5. Natural Field"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("You created a new Grazing farm!"); Console.WriteLine("Press Enter to go to the main Menu"); Console.ReadLine(); break; case 2: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("You created a new Chicken House!"); Console.WriteLine("Press Enter to go to the main Menu"); Console.ReadLine(); break; case 3: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("You created a new Duck House!"); Console.WriteLine("Press Enter to go to the main Menu"); Console.ReadLine(); break; case 4: farm.AddPlowedField(new PlowedField()); Console.WriteLine("You created a new Plowed Field"); Console.WriteLine("Press Enter to go to the main Menu"); Console.ReadLine(); break; case 5: farm.AddNaturalFields(new NaturalFields()); Console.WriteLine("You created a new Natural Field!"); Console.WriteLine("Press Enter to go to the main Menu"); Console.ReadLine(); break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Natural Field"); Console.WriteLine("3. Plowed field"); Console.WriteLine("4. Chicken House"); Console.WriteLine("5. Duck House"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: Console.WriteLine("Congrats you added a grazing field"); Thread.Sleep(1000); farm.AddGrazingField(new GrazingField()); break; case 2: Console.WriteLine("Congrats you've added a natural field"); Thread.Sleep(1000); farm.AddNaturalField(new NaturalField()); break; case 3: Console.WriteLine("Congrats you've added a plowed field"); Thread.Sleep(1000); farm.AddPlowedField(new PlowedField()); break; case 4: Console.WriteLine("Congrats you added a chicken house"); Thread.Sleep(1000); farm.AddChickenHouse(new ChickenHouse()); break; case 5: Console.WriteLine("Congrats you added a duck house."); Thread.Sleep(1000); farm.AddDuckHouse(new DuckHouse()); 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 House"); Console.WriteLine("5. Duck House"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); //This try catch was added due to the fact that if you don't select a facility //and just hit enter/return the program would crash try { 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.AddChickenHouse(new ChickenHouse()); break; case 5: farm.AddDuckHouse(new DuckHouse()); break; } // default: } catch (FormatException ex) { Console.WriteLine(@" **** That is not a valid Facility Choice **** **** Press Enter To Return to Main Menu ****"); Console.ReadLine(); } }
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 { string input = Console.ReadLine(); 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.AddChickenHouse(new ChickenHouse()); break; case 5: farm.AddDuckHouse(new DuckHouse()); break; default: break; } } catch { Console.WriteLine("Incorrect Input, please hit any key to return to main menu"); // Console.ReadLine(); } }
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("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("A new grazing field has been created!"); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("A new plowed field has been created!"); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("A new natural field has been created!"); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("A new chicken house has been created!"); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("A new duck house has been created!"); break; default: Console.WriteLine($"Invalid option: {input}"); break; } }
private static void NewMethod(Farm farm, string input) { switch (Int32.Parse(input)) { case 1: Console.WriteLine("\n\n\n"); Console.WriteLine("Success! Press return key to go back to main menu."); Console.ReadLine(); farm.AddGrazingField(new GrazingField()); break; case 2: Console.WriteLine("\n\n\n"); Console.WriteLine("Success! Press return key to go back to main menu."); Console.ReadLine(); farm.AddPlowedField(new PlowedField()); break; case 3: farm.AddNaturalFields(new NaturalField()); Console.WriteLine("\n\n\n"); Console.WriteLine("Success! You have created a natural field!"); Console.WriteLine("Press return key to go back to main menu."); Console.Write(">"); Console.ReadLine(); break; case 4: Console.WriteLine("\n\n\n"); Console.WriteLine("Success! Press return key to go back to main menu."); Console.ReadLine(); farm.AddChickenHouse(new ChickenHouse()); break; case 5: Console.WriteLine("\n\n\n"); Console.WriteLine("Success! Press return key to go back to main menu."); Console.ReadLine(); farm.AddDuckHouse(new DuckHouse()); break; default: break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Chicken house"); Console.WriteLine("4. Duck House"); Console.WriteLine("5. Natural field"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); break; case 2: farm.AddPlowedField(new PlowedField()); break; case 3: farm.AddChickenHouse(new ChickenHouse()); break; case 4: farm.AddDuckFarm(new DuckFarm()); break; case 5: farm.AddNaturalField(new NaturalField()); break; default: break; } // Console.WriteLine("You Created a Grazing Field"); }
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("> "); string input = Console.ReadLine(); switch (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.AddChickenHouse(new ChickenHouse()); break; case "5": farm.AddDuckHouse(new DuckHouse()); break; default: Console.WriteLine($"{input} Is not a valid input!"); 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(); //TryParse checks to see if the first param in an int, if not it return false an proceeds to else. If true, out(put) a new var/int called choice if (input != "" && int.TryParse(input, out int choice)) { //now we can use the new variable without having to convert it to an int. switch (choice) { case 1: farm.AddGrazingField(new GrazingField()); Console.Clear(); Console.WriteLine("\n\n\n"); Console.WriteLine("You've created a Grazing Field! Now go'on'n'git'ta'plantin'!"); Console.WriteLine("\n\n"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.Clear(); Console.WriteLine("\n\n\n"); Console.WriteLine("You've created a Plowed Field! Now go'on'n'git'ta'plantin'!"); Console.WriteLine("\n\n"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.Clear(); Console.WriteLine("\n\n\n"); Console.WriteLine("You've created a Natural Field! Now go'on'n'git'ta'plantin'!"); Console.WriteLine("\n\n"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); break; case 4: farm.AddChickenCoop(new ChickenCoop()); Console.Clear(); Console.WriteLine("\n\n\n"); Console.WriteLine("You've created a Chicken Coop! You can put a chicken in there!"); Console.WriteLine("\n\n"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.Clear(); Console.WriteLine("\n\n\n"); Console.WriteLine("You've created a Duck House! You can put a Duck in there!"); Console.WriteLine("\n\n"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); break; default: break; } } else { Console.Clear(); Console.WriteLine(); Console.WriteLine("You entered something that was not an option. And that's wrong. You're bad."); Console.WriteLine("\n\n"); Console.WriteLine("Press enter to continue"); Console.ReadLine(); } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Chicken House"); Console.WriteLine("3. Duck House"); Console.WriteLine("4. Plowed field"); Console.WriteLine("5. Natural field"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch ((input)) { case "1": farm.AddGrazingField(new GrazingField()); Console.WriteLine("A New Grazing Field Has Been Added"); Console.WriteLine(); Console.WriteLine($"You Have {farm.GrazingFields.Count()} Grazing Field(s)"); break; case "2": farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("A New Chicken house Has Been Added"); Console.WriteLine(); Console.WriteLine($"You Have {farm.ChickenHouses.Count()} Chicken House(s)"); break; case "3": farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("A New Duck house Has Been Added"); Console.WriteLine(); Console.WriteLine($"You Have {farm.DuckHouses.Count()} Duck House(s)"); break; case "4": farm.AddPlowedField(new PlowedField()); Console.WriteLine("A New Plowed Field Has Been Added"); Console.WriteLine(); Console.WriteLine($"You Have {farm.PlowedFields.Count()} Plowed Field(s)"); break; case "5": farm.AddNaturalField(new NaturalField()); Console.WriteLine("A New Natural Field Has Been Added"); Console.WriteLine(); Console.WriteLine($"You Have {farm.NaturalFields.Count()} Natural Field(s)"); break; default: Console.WriteLine($"Invalid option"); Console.WriteLine(); break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); // Console.WriteLine ("2. Plowed field"); Console.WriteLine("2. Chicken House"); Console.WriteLine("3. Duck House"); Console.WriteLine("4. Natural Field"); Console.WriteLine("5. Plowed Field"); Console.WriteLine("6. Return"); 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()); Console.WriteLine($"You have successfully added a new grazing field! You now have {farm.GrazingFields.Count()} grazing fields. Press ENTER to continue."); Console.ReadLine(); break; case 2: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine($"You have successfully added a new chicken house! You now have {farm.ChickenHouses.Count()} chicken house(s)' Press ENTER to continue."); Console.ReadLine(); break; case 3: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine($"You have successfully added a new duck house! You now have {farm.DuckHouses.Count()} duck house(s). Press ENTER to continue."); Console.ReadLine(); break; case 4: farm.AddNaturalField(new NaturalField()); Console.WriteLine($"You have successfully added a new natural field! You now have {farm.NaturalFields.Count()} natural field(s). Press ENTER to continue."); Console.ReadLine(); break; case 5: farm.AddPlowedField(new PlowedField()); Console.WriteLine($"You have successfully added a new plowed field! You now have {farm.PlowedFields.Count()} plowed field(s). Press ENTER to continue."); Console.ReadLine(); break; case 6: break; default: Console.WriteLine("You entered an invalid entry. Please press ENTER to try again."); Console.ReadLine(); Console.Clear(); CollectInput(farm); break; } } catch { Console.WriteLine("You entered an invalid entry. Press ENTER and try again."); Console.ReadLine(); Console.Clear(); 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 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. 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("> "); string input = Console.ReadLine(); int inputNum = 0; try { inputNum = Int32.Parse(input); if (inputNum < 1 || inputNum > 5) { throw new Exception(); } } catch (Exception) { Program.ShowMessage("invalid input"); CollectInput(farm); } switch (inputNum) { case 1: string GrazingFieldName = Program.GetInput( "Adding a new Grazing Field to the farm. What would you like to call it?" ); farm.AddGrazingField(new GrazingField() { Name = GrazingFieldName, }); Program.ShowMessage($"Successfully added Grazing Field: {GrazingFieldName}."); break; case 2: string PlowedFieldName = Program.GetInput( "Adding a new Plowed Field to the farm. What would you like to call it?" ); farm.AddPlowedField(new PlowedField() { Name = PlowedFieldName, }); Program.ShowMessage($"Successfully added Plowed Field: {PlowedFieldName}."); break; case 3: string NaturalFieldName = Program.GetInput( "Adding a new Natural Field to the farm. What would you like to call it?" ); farm.AddNaturalField(new NaturalField() { Name = NaturalFieldName, }); Program.ShowMessage($"Successfully added Natural Field: {NaturalFieldName}."); break; case 4: string ChickenHouseName = Program.GetInput( "Adding a new Chicken House to the farm. What would you like to call it?" ); farm.AddChickenHouse(new ChickenHouse() { Name = ChickenHouseName }); Program.ShowMessage($"Successfully added Chicken House: {ChickenHouseName}."); break; //Duck House case 5: var DuckHouseName = Program.GetInput("Adding a new Duck House to the farm. What would you like to call it?"); farm.AddDuckHouse(new DuckHouse() { Name = DuckHouseName }); Program.ShowMessage($"Successfully added Duck House: {DuckHouseName}."); 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 House"); Console.WriteLine("5. Duck House"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("Your new grazing field was created!"); foreach (var field in farm.GrazingFields) { Console.WriteLine($"{field.ToString()}"); } Console.WriteLine("Please hit enter"); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("Your new plowed field was created!"); foreach (var field in farm.PlowedFields) { Console.WriteLine($"{field.ToString()}"); } Console.WriteLine("Please hit enter"); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("Your new natural field was created!"); foreach (var field in farm.NaturalFields) { Console.WriteLine($"{field.ToString()}"); } Console.WriteLine("Please hit enter"); Console.ReadLine(); break; case 4: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("Your new chicken house was created!"); foreach (var house in farm.ChickenHouses) { Console.WriteLine($"{house.ToString()}"); } Console.WriteLine("Please hit enter"); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("Your new duck house was created!"); foreach (var house in farm.DuckHouses) { Console.WriteLine($"{house.ToString()}"); } Console.WriteLine("Please hit enter"); Console.ReadLine(); break; default: break; } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Plowed field"); Console.WriteLine("3. Chicken house"); Console.WriteLine("4. Duck house"); Console.WriteLine("5. Natural field"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); int num = -1; if (input != "" && (int.TryParse(input, out num))) { switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("You added a grazing field! Press any key to continue"); Console.WriteLine(); string input1 = Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("You added a plowed field! Press any key to continue"); Console.WriteLine(); string input2 = Console.ReadLine(); break; case 3: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("You added a chicken house! Press any key to continue"); Console.WriteLine(); string input3 = Console.ReadLine(); break; case 4: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("You added a duck house! Press any key to continue"); Console.WriteLine(); string input4 = Console.ReadLine(); break; case 5: farm.AddNaturalField(new NaturalField()); Console.WriteLine("You added a natural field! Press any key to continue"); Console.WriteLine(); string input5 = Console.ReadLine(); break; default: Console.WriteLine("Invalid Selection. Press Any Key to Continue"); string input6 = Console.ReadLine(); break; } } else { Console.WriteLine("Invlaid selection. Press any key to continute."); string input7 = Console.ReadLine(); } //Console.Write("Created a Field"); }
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(); while (true) { Console.WriteLine("Choose what you want to create or hit return to exit"); Console.Write("> "); try { string input = Console.ReadLine(); if (String.IsNullOrEmpty(input)) { break; } else { if (Int32.Parse(input) < 1 || Int32.Parse(input) > 5) { Console.WriteLine("Please enter a valid index range"); } else { switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("Congrats! You've created a grazing field."); Console.WriteLine("Press return to go back to the main menu."); Console.ReadLine(); break; case 2: farm.AddPlowedField(new PlowedField()); Console.WriteLine("Congrats! You've created a plowed field."); Console.WriteLine("Press return to go back to the main menu."); Console.ReadLine(); break; case 3: farm.AddNaturalField(new NaturalField()); Console.WriteLine("Congrats! You've created a natural field."); Console.WriteLine("Press return to go back to the main menu."); Console.ReadLine(); break; case 4: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("Congrats! You've created a duck house."); Console.WriteLine("Press return to go back to the main menu."); Console.ReadLine(); break; case 5: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("Congrats! You've created a chicken house."); Console.WriteLine("Press return to go back to the main menu."); Console.ReadLine(); break; default: break; } break; } } } catch { Console.WriteLine("Please enter a valid index range"); } } }
public static void CollectInput(Farm farm) { Console.WriteLine("1. Grazing field"); Console.WriteLine("2. Chicken house"); Console.WriteLine("3. Plowed field"); Console.WriteLine("4. Natural field"); Console.WriteLine("5. Duck house"); Console.WriteLine(); Console.WriteLine("Choose what you want to create"); Console.Write("> "); string input = Console.ReadLine(); switch (Int32.Parse(input)) { case 1: farm.AddGrazingField(new GrazingField()); Console.WriteLine("Grazing field has been added to facilities."); Console.ReadLine(); break; case 2: farm.AddChickenHouse(new ChickenHouse()); Console.WriteLine("Chicken house has been added to facilities."); if (farm.ChickenHomes.Count == 1) { Console.WriteLine($"There is {farm.ChickenHomes.Count} chicken home!"); } else { Console.WriteLine($"There are {farm.ChickenHomes.Count} chicken homes!"); } Console.ReadLine(); break; case 3: farm.AddPlowedField(new PlowedField()); Console.WriteLine("Plowed field has been added to facilities."); Console.ReadLine(); break; case 4: farm.AddNaturalField(new NaturalField()); Console.WriteLine("Natural field has been added to facilities."); Console.ReadLine(); break; case 5: farm.AddDuckHouse(new DuckHouse()); Console.WriteLine("Duck house has been added to facilities."); if (farm.DuckHomes.Count == 1) { Console.WriteLine($"There is {farm.DuckHomes.Count} duck home!"); } else { Console.WriteLine($"There are {farm.DuckHomes.Count} duck homes!"); } Console.ReadLine(); break; default: break; } }