Esempio n. 1
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;
            }
        }
Esempio n. 3
0
        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;
            }
        }
        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();
            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;

            default:
                break;
            }
        }
Esempio n. 5
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;
            }
        }
Esempio n. 8
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;
            }
        }
Esempio n. 9
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Seed Harvest");
            Console.WriteLine("2. Meat Processor");
            Console.WriteLine("3. Egg Gatherer");
            Console.WriteLine("4. Composter");
            Console.WriteLine("5. Feather Harvester");


            Console.WriteLine();
            Console.WriteLine("What are you processing 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;
                    // default:
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine(@"
                    **** That is not a valid Processing Option ****
                ****     Press Enter To Return to Main Menu      ****");
                Console.ReadLine();
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(@"
                    **** That is not a valid Processing Option ****
                ****     Press Enter To Return to Main Menu      ****");
                Console.ReadLine();
            }
        }
        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;
            }
        }
Esempio n. 11
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;
            }
        }
Esempio n. 12
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;
            }
        }
Esempio n. 14
0
        public static void CollectInput(Farm farm, IGrazing animal, bool clear = true)
        {
            if (clear)
            {
                Console.Clear();
            }



            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].AnimalCount} {(farm.GrazingFields[i].AnimalCount == 1 ? "animal" : "animals")})");
            }

            Console.WriteLine();

            // How can I output the type of animal chosen here?
            Console.WriteLine($"Place the animal where?");

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

            choice = choice - 1;

            int currentListCount        = farm.GrazingFields[choice].AnimalCount;
            int availableSpace          = Convert.ToInt32(farm.GrazingFields[choice].Capacity) - currentListCount;
            int evaluatedAvailableSpace = Math.Sign(availableSpace);

            if (evaluatedAvailableSpace == 1)
            {
                farm.GrazingFields[choice].AddResource(animal);
            }
            else
            {
                Console.Clear();
                Console.WriteLine();
                Console.WriteLine(@"**** That facililty is not large enough ****
****     Please choose another one      ****");
                Console.WriteLine();
                ChooseGrazingField.CollectInput(farm, animal, false);
            }



            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Cow");
            Console.WriteLine("2. Ostrich");
            Console.WriteLine("3. Goat");
            Console.WriteLine("4. Sheep");
            Console.WriteLine("5. Pig");
            Console.WriteLine("6. Dragon");
            Console.WriteLine("7. Duck");
            Console.WriteLine("8. Chicken");
            Console.WriteLine();
            Console.WriteLine("What are you buying today?");

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

            if (input != "" && int.TryParse(input, out int choice))
            {
                switch (choice)
                {
                case 1:
                    if (farm.GrazingFields.Count != 0)
                    {
                        ChooseGrazingField.CollectInput(farm, new Cow());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your cows!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 2:
                    if (farm.GrazingFields.Count != 0)
                    {
                        ChooseGrazingField.CollectInput(farm, new Ostrich());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your ostrichesessss!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 3:
                    if (farm.GrazingFields.Count != 0)
                    {
                        ChooseGrazingField.CollectInput(farm, new Goat());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your gorgeous goats!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 4:
                    if (farm.GrazingFields.Count != 0)
                    {
                        ChooseGrazingField.CollectInput(farm, new Sheep());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your Shipes!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 5:
                    if (farm.GrazingFields.Count != 0)
                    {
                        ChooseGrazingField.CollectInput(farm, new Pig());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your Pigs!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 6:
                    if (farm.GrazingFields.Count != 0)
                    {
                        ChooseGrazingField.CollectInput(farm, new Dragon());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your Dragons!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 7:
                    if (farm.DuckHouses.Count != 0)
                    {
                        ChooseDuckHouse.CollectInput(farm, new Duck());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("You ain't got no duck house!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 8:
                    if (farm.ChickenCoops.Count != 0)
                    {
                        ChooseChickenCoop.CollectInput(farm, new Chicken());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for your Chickens!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

                case 0:
                    Console.WriteLine("You know that's not an option.");
                    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. 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);
            }
        }
Esempio n. 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();
            }
        }
Esempio n. 18
0
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();

            if (farm.GrazingFields.Count() == 0 || farm.GrazingFields.Where(field => field.Animals.Count == field.Capacity).ToList().Count == farm.GrazingFields.Count())
            {
                Console.WriteLine("There are no available grazing fields. Try creating a new one.");
                Console.WriteLine("Press return... or else");
                Console.ReadLine();
            }
            else
            {
                for (int i = 0; i < farm.GrazingFields.Count; i++)
                {
                    // Only display grazing fields that have room
                    if (farm.GrazingFields[i].Animals.Count < farm.GrazingFields[i].Capacity)
                    {
                        Console.WriteLine("=================================================");
                        Console.WriteLine($"{i + 1}. Grazing Field. Current Animal Count: {farm.GrazingFields[i].Animals.Count}");

                        // Group animals by their type to display their counts
                        List <IGrouping <string, IGrazing> > groupedAnimals = farm.GrazingFields[i].Animals.GroupBy(anml => anml.Type).ToList();

                        foreach (IGrouping <string, IGrazing> anml in groupedAnimals)
                        {
                            Console.WriteLine($"{anml.Key}: {anml.Count()}");
                        }
                        Console.WriteLine("=================================================");
                    }
                }

                Console.WriteLine();

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

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


                    if (farm.GrazingFields[choice - 1].Animals.Count < farm.GrazingFields[choice - 1].Capacity)
                    {
                        farm.GrazingFields[choice - 1].AddResource(animal);
                    }
                    else if (farm.GrazingFields.Where(field => field.Animals.Count < field.Capacity).ToList().Count > 0)
                    {
                        Console.Write("Facility is full. Please select another facility. Press any key to continue...");
                        Console.ReadLine();
                        ChooseGrazingField.CollectInput(farm, animal);
                    }
                    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();
                    ChooseGrazingField.CollectInput(farm, animal);
                }
                catch (System.ArgumentOutOfRangeException)
                {
                    Console.WriteLine("The grazing field you selected does not exist\nPress return to continue");
                    Console.ReadLine();
                    ChooseGrazingField.CollectInput(farm, animal);
                }
            }
        }
        public static void CollectInput(Farm farm, IGrazing animal)
        {
            Console.Clear();

            Console.WriteLine($"How many {animal.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 <IGrazing> manyAnimals = Enumerable.Repeat(animal, number).ToList();


            for (int i = 0; i < farm.GrazingFields.Count; i++)
            {
                if (farm.GrazingFields[i].animalCount() == 1)
                {
                    Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].animalCount()} animal)");
                }
                else if (farm.GrazingFields[i].animalCount() < farm.GrazingFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Grazing Field ({farm.GrazingFields[i].animalCount()} animals)");
                }
                // else
                // {
                //   Console.WriteLine($"{i + 1}. Grazing Field is full. ({farm.GrazingFields[i].animalCount()} animals)");
                // }
            }

            Console.WriteLine();

            // How can I output the type of animal chosen here?
            Console.WriteLine($"Place the {animal.Type} where?");

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

            // check if grazingFields is at capacity and if so add an animal


            if (farm.GrazingFields[choice].animalCount()
                + manyAnimals.Count() <= farm.GrazingFields[choice].Capacity)
            {
                farm.GrazingFields[choice].AddResource(manyAnimals);
            }
            else
            // if GrazingFields is at capacity then don't add animal and display this message
            {
                Console.Clear();
                Console.WriteLine($@"
*************** I'm sorry, that facility is at capacity. ***************
**************      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 field
                Console.WriteLine($@"
 _______________________________________________
| Would you like to create a new Grazing Field? |
|         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 GrazingField and add it to the farm.
                // go to the ChooseGrazingField menu and pass the animal and farm
                case 1:
                    farm.AddGrazingField(new GrazingField());
                    Console.Clear();
                    Console.WriteLine("Success! One Grazing Field Added. Press enter to continue.");
                    Console.ReadLine();
                    ChooseGrazingField.CollectInput(farm, animal);
                    break;

                case 2:
                    break;
                }
            }
        }
Esempio n. 20
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)
        {
            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");
                // }
            }
        }
Esempio n. 22
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();
            }
        }
        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);
            }
        }
        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)
        {
            Console.WriteLine("1. Chicken");
            Console.WriteLine("2. Cow");
            Console.WriteLine("3. Duck");
            Console.WriteLine("4. Pig");
            Console.WriteLine("5. Goat");
            Console.WriteLine("6. Ostrich");
            Console.WriteLine("7. Sheep");

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

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

            try
            {
                if (int.Parse(choice) <= 7 && int.Parse(choice) >= 1)
                {
                    switch (Int32.Parse(choice))
                    {
                    case 1:
                        ChooseChickenCoop.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 Pig());
                        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:
                        Console.WriteLine("Invalid option. Please try again.");
                        Thread.Sleep(2000);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Invalid option. Please try again.");
                    Thread.Sleep(2000);
                    DisplayBanner();
                    PurchaseLivestock.CollectInput(farm);
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("Invalid option. Please try again.");
                Thread.Sleep(2000);
                DisplayBanner();
                PurchaseLivestock.CollectInput(farm);
            }
        }
Esempio n. 26
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);
            }
        }
Esempio n. 27
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();
            }
        }
        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);
        }
Esempio n. 29
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);
            }
        }