Пример #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;
            }
        }
Пример #3
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;
            }
        }
Пример #6
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;
            }
        }
Пример #8
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;
            }
        }
Пример #9
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;
            }
        }
        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. 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. 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);
            }
        }
Пример #14
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();
            }
        }
Пример #15
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);
            }
        }
        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);
            }
        }
        public static void CollectInput(Farm farm, Duck Duck)
        {
            Console.Clear();

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

                Console.WriteLine();

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

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


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

            List <DuckHouse> openDuckHouses = new List <DuckHouse>();

            List <DuckHouse> sortedHouses = farm.DuckHouse.Where(duckHouse => (duckHouse.Capacity - 1) >= duckHouse.CurrentStock()).ToList();

            for (int i = 0; i < sortedHouses.Count; i++)
            {
                if ((sortedHouses[i].Capacity - 1) >=
                    sortedHouses[i].CurrentStock())
                {
                    openDuckHouses.Add(sortedHouses[i]);
                    Console.WriteLine($"{i + 1}. Duck House (Current Stock: {sortedHouses[i].CurrentStock()})");

                    sortedHouses[i].ShowAnimalsByType();
                }
            }

            Console.WriteLine();

            if (openDuckHouses.Count > 0)
            {
                Console.WriteLine($"Place the animal where?");
                Console.Write("> ");
                try
                {
                    int choice = Int32.Parse(Console.ReadLine());
                    if (animal is Duck)
                    {
                        try
                        {
                            sortedHouses[choice - 1].AddResource(animal);
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            Console.WriteLine("Invalid option. Please try again.");
                            Thread.Sleep(2000);
                            ChooseDuckHouse.CollectInput(farm, new Duck());
                        }
                    }
                    else
                    {
                        Console.WriteLine("There are no matching facilities available. Please create one first.");
                        Thread.Sleep(2000);
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine("Invalid option. Please try again.");
                    Thread.Sleep(2000);
                    ChooseDuckHouse.CollectInput(farm, new Duck());
                }
            }

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Пример #20
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)
        {
            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;
            }
        }
Пример #22
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;
            }
        }
Пример #23
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, IEggFeatherProducing duck)
        {
            Console.Clear();



            Console.WriteLine($"How many ducks would you like to add?");


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


            List <IEggFeatherProducing> manyDucks = Enumerable.Repeat(duck, number).ToList();

            for (int i = 0; i < farm.DuckHouses.Count; i++)
            {
                //if single duck - use the singular message
                if (farm.DuckHouses[i].duckCount() == 1)
                {
                    Console.WriteLine($"{i + 1}:  This duck house has 1 duck");
                }
                else
                {
                    if (farm.DuckHouses[i].duckCount() < farm.DuckHouses[i].Capacity)
                    {
                        Console.WriteLine($"{i + 1} :  Duck House has {farm.DuckHouses[i].duckCount()} ducks");
                    }
                    // else
                    // {
                    //     Console.WriteLine($"{i + 1} :  Duck House is full {farm.DuckHouses[i].duckCount()}");
                    // }
                }
            }

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

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


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

************************************************************************
**************      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 Duck 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.AddDuckHouse(new DuckHouse());
                    Console.Clear();
                    Console.WriteLine("Success! One Duck House Added. Press enter to continue.");
                    Console.ReadLine();
                    ChooseDuckHouse.CollectInput(farm, duck);
                    break;

                case 2:
                    break;
                }
            }
        }
Пример #25
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();
            }
        }