public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Chicken");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 3:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            default:
                break;
            }
        }
Example #2
0
        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();
            // README code
            Console.WriteLine("Choose an animal to purchase.");
            // Old code
            // Console.WriteLine ("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            try
            {
                switch (Int32.Parse(choice))
                {
                case 1:
                    ChooseChickenHouse.CollectInput(farm, new Chicken());
                    break;

                case 2:
                    ChooseGrazingField.CollectInput(farm, new Cow());
                    break;

                case 3:
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                    break;

                case 4:
                    ChooseGrazingField.CollectInput(farm, new Goat());
                    break;

                case 5:
                    ChooseGrazingField.CollectInput(farm, new Ostrich());
                    break;

                case 6:
                    ChooseGrazingField.CollectInput(farm, new Pig());
                    break;

                case 7:
                    ChooseGrazingField.CollectInput(farm, new Sheep());
                    break;

                default:
                    break;
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex);
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Duck");
            Console.WriteLine("4. Goat");
            Console.WriteLine("5. Pig");
            Console.WriteLine("6. Sheep");
            Console.WriteLine("7. Chicken");
            Console.WriteLine("8. Go Back To Main Menu");


            Console.WriteLine();
            if (ThereIsNoRoomForTheAnimalBeingPurchased)
            {
                Console.WriteLine("Sorry, but you don't have anywhere to put that animal. Please make a different selection.");
            }

            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 3:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            case 4:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case 6:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            case 7:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 8:
                break;

            default:
                break;
            }
        }
Example #4
0
        public static void CollectInput(Farm farm)
        {
            // print option of animals to buy
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Goat");
            Console.WriteLine("4. Pig");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            // read the user selection
            string choice = Console.ReadLine();

            // conditional to print from user selection
            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                //prints confirmation
                break;

            default:
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                //prints confirmation
                break;

            case 3:
                ChooseGrazingField.CollectInput(farm, new Goat());
                //prints confirmation
                break;

            case 4:
                ChooseGrazingField.CollectInput(farm, new Pig());
                //prints confirmation
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                //prints confirmation
                break;

            case 6:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                //prints confirmation
                break;

            case 7:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                //prints confirmation
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            var animalList = new List <IResource> ();

            animalList.Add(new Chicken());
            animalList.Add(new Cow());
            animalList.Add(new Duck());
            animalList.Add(new Goat());
            animalList.Add(new Ostrich());
            animalList.Add(new Pig());
            animalList.Add(new Sheep());

            foreach (var animal in animalList)
            {
                var animalIndex = animalList.IndexOf(animal) + 1;
                Console.WriteLine($"{animalIndex}. {animal}");
            }

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:

                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 3:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            case 4:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 6:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case 7:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Goat");
            Console.WriteLine("3. Ostrich");
            Console.WriteLine("4. Pig");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            // default:
            //     break;
            case 2:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;
            // default:
            //     break;

            case 3:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            // default:
            //     break;
            case 4:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            // default:
            //     break;
            case 5:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            case 6:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 7:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            default:
                break;
            }
        }
Example #7
0
        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();

            Console.WriteLine("How many?");
            Console.Write("> ");
            int amount = Convert.ToInt32(Console.ReadLine());

            switch (choice)
            {
            case "1":
                ChooseChickenHouse.CollectInput(farm, amount);
                break;

            case "2":
                ChooseGrazingField.CollectInput(farm, new Cow(), amount);
                break;

            case "3":
                ChooseDuckHouse.CollectInput(farm, amount);
                break;

            case "4":
                ChooseGrazingField.CollectInput(farm, new Goat(), amount);
                break;

            case "5":
                ChooseGrazingField.CollectInput(farm, new Ostrich(), amount);
                break;

            case "6":
                ChooseGrazingField.CollectInput(farm, new Pig(), amount);
                break;

            case "7":
                ChooseGrazingField.CollectInput(farm, new Sheep(), amount);
                break;

            default:
                Console.WriteLine($"{choice} Is not a valid input!");
                Console.ReadLine();
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Duck");
            Console.WriteLine("4. Pig");
            Console.WriteLine("5. Goat");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Sheep");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 3:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            case 4:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case 6:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 7:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            default:
                Console.Clear();
                Console.Write("Not a valid option. Press enter to try again");
                Console.ReadLine();
                Console.Clear();
                PurchaseStock.CollectInput(farm);
                break;
            }
        }
Example #9
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Goat");
            Console.WriteLine("3. Ostrich");
            Console.WriteLine("4. Pig");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case 3:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 4:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            case 6:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 7:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            default:
                //   throw new ArgumentOutOfRangeException("Unknown value");
                Console.WriteLine("That's not a valid choice! Please try again!");
                Console.ReadLine();
                break;
            }
        }
Example #10
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Pig");
            Console.WriteLine("3. Goat");
            Console.WriteLine("4. Ostrich");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (choice)
            {
            case "1":
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case "2":
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case "3":
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case "4":
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case "5":
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            case "6":
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case "7":
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            default:
                Console.WriteLine($"Invalid option");
                Console.WriteLine();
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Goat");
            Console.WriteLine("4. Pig");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            // Giving ourselves the ability to create new animals and calling the CollectInput method to place the animal in an available grazing field
            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 3:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case 4:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            case 6:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 7:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            default:
                break;
            }
        }
Example #12
0
        public static void CollectInput(Farm farm)
        {
            try
            {
                Console.WriteLine("1. Cow");
                Console.WriteLine("2. Ostrich");
                Console.WriteLine("3. Pig");
                Console.WriteLine("4. Sheep");
                Console.WriteLine("5. Goat");
                Console.WriteLine("6. Duck");
                Console.WriteLine("7. Chicken");

                Console.WriteLine();
                Console.WriteLine("What are you buying today?");

                Console.Write("> ");
                string choice = Console.ReadLine();

                switch (Int32.Parse(choice))
                {
                case 1:
                    ChooseGrazingField.CollectInput(farm, new Cow());
                    break;

                case 2:
                    ChooseGrazingField.CollectInput(farm, new Ostrich());
                    break;

                case 3:
                    ChooseGrazingField.CollectInput(farm, new Pig());
                    break;

                case 4:
                    ChooseGrazingField.CollectInput(farm, new Sheep());
                    break;

                case 5:
                    ChooseGrazingField.CollectInput(farm, new Goat());
                    break;

                case 6:
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                    break;

                case 7:
                    ChooseChickenHouse.CollectInput(farm, new Chicken());
                    break;

                default:
                    Console.WriteLine("Please enter a valid selction.");
                    Thread.Sleep(1000);
                    Utils.Clear();
                    CollectInput(farm);
                    break;
                }
            }
            catch
            {
                Console.WriteLine("Please enter a valid selction.");
                Thread.Sleep(1000);
                Utils.Clear();
                CollectInput(farm);
            }
        }
Example #13
0
        public static void CollectInput(Farm farm)
        {
            //farm refers to every grazing field

            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Pig");
            Console.WriteLine("3. Goat");
            Console.WriteLine("4. Ostrich");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");
            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            //set a string to the number typed in

            switch (Int32.Parse(choice))

            // setting the choice to an integer

            {
            case 1:

                ChooseGrazingField.CollectInput(farm, new Cow());

                break;

            case 2:

                ChooseGrazingField.CollectInput(farm, new Pig());

                break;

            case 3:

                ChooseGrazingField.CollectInput(farm, new Goat());

                break;

            case 4:

                ChooseGrazingField.CollectInput(farm, new Ostrich());



                break;

            case 5:

                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            case 6:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 7:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Boolean choiceBoolean = true;
            int     choice        = -1;

            Console.WriteLine("0. Back to main menu");
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Pig");
            Console.WriteLine("3. Chicken");
            Console.WriteLine("4. Duck");
            Console.WriteLine("5. Goat");
            Console.WriteLine("6. Ostrich");
            Console.WriteLine("7. Sheep");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");
            while (choiceBoolean)
            {
                Console.Write("> ");


                try
                {
                    choice = Int32.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("No number detected");
                }
                if (choice < 0 || choice > 7)
                {
                    Console.WriteLine("Please input a number corresponding to a choice");
                }
                else
                {
                    choiceBoolean = false;
                }
            }
            switch (choice)
            {
            case 0:
                break;

            case 1:
                ChooseGrazingField.CollectInput(farm, new Cow());
                break;

            case 2:
                ChooseGrazingField.CollectInput(farm, new Pig());
                break;

            case 3:
                ChooseChickenHouse.CollectInput(farm, new Chicken());
                break;

            case 4:
                ChooseDuckHouse.CollectInput(farm, new Duck());
                break;

            case 5:
                ChooseGrazingField.CollectInput(farm, new Goat());
                break;

            case 6:
                ChooseGrazingField.CollectInput(farm, new Ostrich());
                break;

            case 7:
                ChooseGrazingField.CollectInput(farm, new Sheep());
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            var ChickenList = new List <Chicken>();

            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Pig");
            Console.WriteLine("4. Goat");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Duck");
            Console.WriteLine("7. Chicken");

            Console.WriteLine();

            while (true)
            {
                Console.WriteLine("What are you buying today? Hit return to exit");
                Console.Write("> ");
                // try
                // {
                string choice = Console.ReadLine();
                if (String.IsNullOrEmpty(choice))
                {
                    break;
                }
                else
                {
                    if (Int32.Parse(choice) < 1 || Int32.Parse(choice) > 7)
                    {
                        Console.WriteLine("Please enter a valid index range");
                    }
                    else
                    {
                        switch (Int32.Parse(choice))
                        {
                        case 1:
                            ChooseGrazingField.CollectInput(farm, new Cow());
                            break;

                        case 2:
                            ChooseGrazingField.CollectInput(farm, new Ostrich());
                            break;

                        case 3:
                            ChooseGrazingField.CollectInput(farm, new Pig());
                            break;

                        case 4:
                            ChooseGrazingField.CollectInput(farm, new Goat());
                            break;

                        case 5:
                            ChooseGrazingField.CollectInput(farm, new Sheep());
                            break;

                        case 6:
                            ChooseDuckHouse.CollectInput(farm, new Duck());
                            break;

                        case 7:
                            Console.WriteLine("How many Chickens would you like to buy?");
                            try
                            {
                                int amount = int.Parse(Console.ReadLine());
                                for (int i = 0; i < amount; i++)
                                {
                                    ChickenList.Add(new Chicken());
                                }
                            }
                            catch
                            {
                            }
                            ChooseChickenHouse.CollectInput(farm, ChickenList);
                            break;

                        default:
                            break;
                        }
                        break;
                    }
                }
                // }
                // catch
                // {

                //     Console.WriteLine("Ibroke at the loop");
                //     Console.WriteLine("Please enter a valid index range");
                // }
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Chicken");
            Console.WriteLine("4. Duck");
            Console.WriteLine("5. Goat");
            Console.WriteLine("6. Pig");
            Console.WriteLine("7. Sheep");
            Console.WriteLine("8. Return");
            Console.WriteLine();
            Console.WriteLine("What are you buying today?");
            Console.Write("> ");
            string choice = Console.ReadLine();

            try {
                switch (Int32.Parse(choice))
                {
                case 1:
                    ChooseGrazingField.CollectInput(farm, new Cow());
                    break;

                case 2:
                    ChooseGrazingField.CollectInput(farm, new Ostrich());
                    break;

                case 3:
                    ChooseChickenHouse.CollectInput(farm, new Chicken());
                    break;

                case 4:
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                    break;

                case 5:
                    ChooseGrazingField.CollectInput(farm, new Goat());
                    break;

                case 6:
                    ChooseGrazingField.CollectInput(farm, new Pig());
                    break;

                case 7:
                    ChooseGrazingField.CollectInput(farm, new Sheep());
                    break;

                case 8:
                    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);
            }
        }
Example #17
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Sheep");
            Console.WriteLine("4. Goat");
            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:
                    ChooseGrazingField.CollectInput(farm, new Cow());
                    break;

                case 2:
                    ChooseGrazingField.CollectInput(farm, new Ostrich());
                    break;

                case 3:
                    ChooseGrazingField.CollectInput(farm, new Sheep());
                    break;

                case 4:
                    ChooseGrazingField.CollectInput(farm, new Goat());
                    break;

                case 5:
                    ChooseGrazingField.CollectInput(farm, new Pig());
                    break;

                case 6:
                    ChooseChickenHouse.CollectInput(farm, new Chicken());
                    break;

                case 7:
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                    break;
                    // default:
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine(@"
                **** That is not a valid Animal Choice ****
            ****     Press Enter To Return to Main Menu      ****");
                Console.ReadLine();
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(@"
                **** That is not a valid Animal Choice ****
            ****     Press Enter To Return to Main Menu      ****");
                Console.ReadLine();
            }
        }
Example #18
0
        // Displays Purchase Stock sub-menu options to user

        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Chicken");
            Console.WriteLine("4. Duck");
            Console.WriteLine("5. Goat");
            Console.WriteLine("6. Pig");
            Console.WriteLine("7. Sheep");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");

            // stores user's input in variable "choice"
            string choice = Console.ReadLine();

            // try and catch statements prevent the program from closing if the user's chooses an invalid option
            try
            {
                // The user's input is parsed to an integer, and a switch statement proceses the user's choice, adding a new animal to the farm.

                switch (Int32.Parse(choice))
                {
                case 1:
                    ChooseGrazingField.CollectInput(farm, new Cow());
                    break;

                case 2:
                    ChooseGrazingField.CollectInput(farm, new Ostrich());
                    break;

                case 3:
                    ChooseChickenHouse.CollectInput(farm, new Chicken());
                    break;

                case 4:
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                    break;

                case 5:
                    ChooseGrazingField.CollectInput(farm, new Goat());
                    break;

                case 6:
                    ChooseGrazingField.CollectInput(farm, new Pig());
                    break;

                case 7:
                    ChooseGrazingField.CollectInput(farm, new Sheep());
                    break;

                // integers other than 1-7 result in the default message
                default:
                    Console.WriteLine();
                    Console.WriteLine("Invalid input! Press any key to return home");
                    Console.ReadLine();
                    break;
                }
            }

            // Catches an error if the user enters input that can't be parsed to an integer, informs the user, and returns the user to the main menu
            catch (FormatException)
            {
                Console.WriteLine();
                Console.WriteLine("Invalid input! Press any key to return home");
                Console.ReadLine();
            }
        }
Example #19
0
        public static void CollectInput(Farm farm, Chicken chicken)
        {
            Console.Clear();

            if (farm.ChickenHouses.Count() == 0 || farm.ChickenHouses.Where(field => field.Chickens.Count == field.Capacity).ToList().Count == farm.ChickenHouses.Count())
            {
                Console.WriteLine("There are no available chicken houses. Try creating a new one.");
                Console.WriteLine("Press return... or else");
                Console.ReadLine();
            }
            else
            {
                for (int i = 0; i < farm.ChickenHouses.Count; i++)
                {
                    // Only display chicken houses that have room
                    if (farm.ChickenHouses[i].Chickens.Count < farm.ChickenHouses[i].Capacity)
                    {
                        Console.WriteLine($"{i + 1}. Chicken House. Current Chicken Count: {farm.ChickenHouses[i].Chickens.Count}");
                    }
                }

                Console.WriteLine();

                // How can I output the type of animal chosen here?
                Console.WriteLine($"Place the {chicken.GetType().ToString().Split(".")[3]} where?");

                Console.Write("> ");
                try
                {
                    int choice = Int32.Parse(Console.ReadLine());

                    if (farm.ChickenHouses[choice - 1].Chickens.Count < farm.ChickenHouses[choice - 1].Capacity)
                    {
                        farm.ChickenHouses[choice - 1].AddResource(chicken);
                    }
                    else if (farm.ChickenHouses.Where(field => field.Chickens.Count < field.Capacity).ToList().Count > 0)
                    {
                        Console.Write("Facility is full. Please select another facility. Press any key to continue...");
                        Console.ReadLine();
                        ChooseChickenHouse.CollectInput(farm, chicken);
                    }
                    else
                    {
                        Console.Write("All facilities full. Press any key to continue...");
                        Console.ReadLine();
                    }
                }
                catch (System.FormatException)
                {
                    Console.WriteLine("Please enter one of the specified options...\nI love you.\nPress return to continue");
                    Console.ReadLine();
                    ChooseChickenHouse.CollectInput(farm, chicken);
                }
                catch (System.ArgumentOutOfRangeException)
                {
                    Console.WriteLine("The chicken house you selected does not exist\nPress return to continue");
                    Console.ReadLine();
                    ChooseChickenHouse.CollectInput(farm, chicken);
                }
            }
        }
        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);
            }
        }
Example #21
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Pig");
            Console.WriteLine("4. Goat");
            Console.WriteLine("5. Sheep");
            Console.WriteLine("6. Chicken");
            Console.WriteLine("7. Duck");

            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

            Console.Write("> ");
            string choice = Console.ReadLine();

            int num = -1;

            if (choice != "" && (int.TryParse(choice, out num)))
            {
                switch (Int32.Parse(choice))
                {
                case 1:
                    ChooseGrazingField.CollectInput(farm, new Cow());
                    break;

                case 2:
                    ChooseGrazingField.CollectInput(farm, new Ostrich());
                    break;

                case 3:
                    ChooseGrazingField.CollectInput(farm, new Pig());
                    break;

                case 4:
                    ChooseGrazingField.CollectInput(farm, new Goat());
                    break;

                case 5:
                    ChooseGrazingField.CollectInput(farm, new Sheep());
                    break;

                case 6:
                    ChooseChickenHouse.CollectInput(farm, new Chicken());
                    break;

                case 7:
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                    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();
            }
        }
Example #22
0
        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, IEggFeatherMeatProducing chicken)
        {
            Console.Clear();

            Console.WriteLine($"How many {chicken.Type}s would you like to add?");

            // store that number in the variable "number"
            // Use Enumberable.Repeat() to put x("number") amount of animals("animal") in new list named "manyAnimals"
            Console.Write("> ");

            int number = Int32.Parse(Console.ReadLine());

            List <IEggFeatherMeatProducing> manyChickens = Enumerable.Repeat(chicken, number).ToList();

            Console.Clear();

            for (int i = 0; i < farm.ChickenHouses.Count; i++)
            {
                if (farm.ChickenHouses[i].chickenCount() == 1)
                {
                    Console.WriteLine($"{i + 1}: This chicken house has 1 chicken");
                }
                else if (farm.ChickenHouses[i].chickenCount() < farm.ChickenHouses[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}: Chicken House has ({farm.ChickenHouses[i].chickenCount()}) chickens");
                }
                // else
                // {
                //     Console.WriteLine($"{i + 1}: Chicken House is full. {farm.ChickenHouses[i].chickenCount()}");
                // }
                // }
            }

            Console.WriteLine();

            Console.WriteLine($"Place the Chicken where?");

            Console.Write("> ");
            int choice = Int32.Parse(Console.ReadLine()) - 1;

            if (farm.ChickenHouses[choice].chickenCount() + manyChickens.Count() <= farm.ChickenHouses[choice].Capacity)
            {
                farm.ChickenHouses[choice].AddResource(manyChickens);
            }
            else
            {
                Console.WriteLine($@"
~ I'm sorry! That facility can only hold ({farm.ChickenHouses[0].Capacity}) chickens ~

************************************************************************
**************      Please choose another facility.     ****************
********** If there are no other natural fields, build one.  ***********
************************************************************************

-----------------------((press enter to continue))----------------------
");
                Console.ReadLine();

                // after user hits enter ask if they want to create a new chicken house
                Console.WriteLine($@"
 _______________________________________________
| Would you like to create a new Chicken house? |
|         Press 1 for yes or 2 for no           |
 -----------------------------------------------
");
                Console.Write("> ");
                // collect the user's input and store it in the string "input"
                string input = Console.ReadLine();
                // parse the string and create a switch case
                switch (Int32.Parse(input))
                {
                // create a new chicken house and add it to the farm.
                // go to the chickenhouse menu and pass the farm and chicken in.
                case 1:
                    farm.AddChickenHouse(new ChickenHouse());
                    Console.Clear();
                    Console.WriteLine("Success! One Chicken House Added. Press enter to continue.");
                    Console.ReadLine();
                    ChooseChickenHouse.CollectInput(farm, chicken);
                    break;

                case 2:
                    break;
                }
            }
        }
        public static void CollectInput(Farm farm)
        {
            bool doOver;

            do
            {
                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();
                doOver = false;
                List <ChickenHouse> availableChickenHouses = FilterChickenHouses(farm);
                List <DuckHouse>    availableDuckHouses    = FilterDuckHouses(farm);
                List <GrazingField> availableGrazingFields = FilterGrazingFields(farm);
                int parsedChoice;
                try
                {
                    parsedChoice = Int32.Parse(choice);
                }
                catch (Exception)
                {
                    parsedChoice = 0;
                }

                switch (parsedChoice)
                {
                case 1:
                    // Chicken
                    if (availableChickenHouses.Count > 0)
                    {
                        ChooseChickenHouse.CollectInput(availableChickenHouses, new Chicken());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 2:
                    // cow
                    if (availableGrazingFields.Count > 0)
                    {
                        ChooseGrazingField.CollectInput(availableGrazingFields, new Cow());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 3:
                    // duck
                    if (availableDuckHouses.Count > 0)
                    {
                        chooseDuckHouse.CollectInput(availableDuckHouses, new Duck());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 4:
                    // goat
                    if (availableGrazingFields.Count > 0)
                    {
                        ChooseGrazingField.CollectInput(availableGrazingFields, new Goat());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 5:
                    // ostrich
                    if (availableGrazingFields.Count > 0)
                    {
                        ChooseGrazingField.CollectInput(availableGrazingFields, new Ostrich());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 6:
                    // pig
                    if (availableGrazingFields.Count > 0)
                    {
                        ChooseGrazingField.CollectInput(availableGrazingFields, new Pig());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 7:
                    // sheep
                    if (availableGrazingFields.Count > 0)
                    {
                        ChooseGrazingField.CollectInput(availableGrazingFields, new Sheep());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                default:
                    Program.ShowMessage("Invalid selection.  Please choose again.");
                    doOver = true;
                    break;
                }
            } while (doOver);
        }