Ejemplo n.º 1
0
        public static void CollectInput(Farm farm, ISeedAndCompostProducing plant)
        {
            Console.Clear();
            Console.WriteLine("1. Natural Field");
            Console.WriteLine("2. Plowed Field");

            Console.WriteLine();
            Console.WriteLine("Where would you like to plant them?");

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

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

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");

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

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

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

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                break;

            case 3:
                ChooseNaturalField.CollectInput(farm, new Sunflower());
                break;

            case 4:
                ChooseNaturalField.CollectInput(farm, new Wildflower());
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");


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

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

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

            case "2":
                ChooseSunflowerField.CollectInput(farm, new Sunflower());

                break;

            case "3":
                ChooseNaturalField.CollectInput(farm, new Wildflower());
                break;

            default:
                Console.WriteLine($"Invalid option");
                Console.WriteLine();
                break;
            }
        }
Ejemplo n.º 4
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Natural");
            Console.WriteLine("2. Plowed");

            Console.WriteLine();
            Console.WriteLine("What type of field?");

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

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

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                break;

            default:
                break;
            }
        }
Ejemplo n.º 5
0
        public static void CollectInput(Farm farm)
        {
            // print option of fields for sunflowers
            Console.WriteLine("Are your sunflowers for food or pleasure?");
            Console.WriteLine("1. Pleasure- send them to a Natural Field");
            Console.WriteLine("2. Food- send them to a Plowed Field");

            string subChoice = Console.ReadLine();

            switch (Int32.Parse(subChoice))
            {
            case 1:
                ChooseNaturalField.CollectInput(farm, new Sunflower());
                //prints confirmation of natural field creation.
                break;

            default:
                break;

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                //prints confirmation of plowed field creation.

                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflowers");
            Console.WriteLine("3. Wildflowers");

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

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

            //depending on the input selected, we determine where the selection goes in the appropiate field. If one doesn't exist it will state that.
            switch (Int32.Parse(choice))
            {
            case 1:
                ChoosePlowedField.CollectInput(farm, new Sesame());
                break;

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflowers());
                break;

            case 3:
                ChooseNaturalField.CollectInput(farm, new Wildflowers());
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm, Sunflower Sunflower)
        {
            Console.Clear();

            Console.WriteLine("1. Natural Field");
            Console.WriteLine("2. Plowed Field");

            Console.WriteLine();
            // README code
            Console.WriteLine("Choose which type of field to plant the Sunflower seed in.");
            // Old code
            // Console.WriteLine ("What are you buying today?");

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

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

            case 2:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                break;
            }
        }
Ejemplo n.º 8
0
        public static void CollectInput(Farm farm)
        {
            Console.Clear();
            Console.WriteLine("1. Plowed Field");
            Console.WriteLine("2. Natural Field");

            Console.WriteLine();
            Console.WriteLine("In which type of field would you like to plant the sunflower?");

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

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

            case 2:
                ChooseNaturalField.CollectInput(farm, new Sunflower());
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");

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

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

            try
            {
                if (int.Parse(choice) <= 3 && int.Parse(choice) >= 1)
                {
                    switch (Int32.Parse(choice))
                    {
                    case 1:
                        ChoosePlowedField.CollectInput(farm, new Sesame());
                        break;

                    case 2:
                        ChooseSunflowerField <Sunflower> .CollectInput(farm, new Sunflower());

                        break;

                    case 3:
                        ChooseNaturalField.CollectInput(farm, new Wildflower());
                        break;

                    default:
                        Console.WriteLine("Invalid option. Redirecting to main menu.");
                        Thread.Sleep(2000);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Invalid option. Please try again.");
                    Thread.Sleep(2000);
                    DisplayBanner();
                    PurchaseSeed.CollectInput(farm);
                }
            }
            catch (FormatException)
            {
                Console.WriteLine("Invalid option. Please try again.");
                Thread.Sleep(2000);
                DisplayBanner();
                PurchaseSeed.CollectInput(farm);
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("0. Return to Main Menu");
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");


            Console.WriteLine();
            Console.WriteLine("Choose seed to purchase.");

            Console.Write("> ");

            while (true)
            {
                try
                {
                    int choice = Int32.Parse(Console.ReadLine());
                    switch (choice)
                    {
                    case 0:
                        break;

                    case 1:
                        ChoosePlowedField.CollectInput(farm, new Sesame());
                        break;

                    case 2:
                        ChooseBothPlantFields.CollectInput(farm, new Sunflower());
                        break;

                    case 3:
                        ChooseNaturalField.CollectInput(farm, new Wildflower());
                        break;

                    default:
                        Console.WriteLine("That is not the correct input.  Please try again.");
                        Console.Write("> ");
                        break;
                    }
                    if (choice >= 0 && choice <= 3)
                    {
                        break;
                    }
                }
                catch
                {
                    Console.WriteLine("That is not the correct input.  Please try again.");
                    Console.Write("> ");
                }
            }
            Console.Write("");
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine(" 1. Sesame");
            Console.WriteLine(" 2. Sunflower");
            Console.WriteLine(" 3. Wildflower");

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

            Console.WriteLine("  Choose seed to purchase");

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

            if (seedChoice == "1")
            {
                seedChoice = "Sesame";
            }

            if (seedChoice == "2")
            {
                seedChoice = "Sunflower";
            }

            if (seedChoice == "3")
            {
                seedChoice = "Wildflower";
            }

            Console.WriteLine($"  How many {seedChoice} would you like to plant?");

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

            if (seedChoice == "Sesame")
            {
                ChoosePlowedField.CollectInput(farm, seedChoice, amountChoice);
            }
            if (seedChoice == "Sunflower")
            {
                ChooseSunflowerField.CollectInput(farm, seedChoice, amountChoice);
            }
            if (seedChoice == "Wildflower")
            {
                ChooseNaturalField.CollectInput(farm, seedChoice, amountChoice);
            }
        }
        public static void CollectInput(Farm farm)
        {
            try
            {
                Console.WriteLine("1. Sunflower");
                Console.WriteLine("2. Wildflower");
                Console.WriteLine("3. Sesame");

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

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

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

                case 2:
                    ChooseNaturalField.CollectInput(farm, new Wildflower());
                    break;

                case 3:
                    ChoosePlowedField.CollectInput(farm, new Sesame());
                    break;

                default:
                    Console.WriteLine("Please enter a valid selction.");
                    Thread.Sleep(1000);
                    Utils.Clear();
                    CollectInput(farm);
                    break;
                }
            }
            catch
            {
                Console.WriteLine("Please enter a valid selection.");
                Thread.Sleep(1000);
                Utils.Clear();
                CollectInput(farm);
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");
            Console.WriteLine("4. Return");
            Console.WriteLine();
            Console.WriteLine("What seed are you buying today?");
            Console.Write(">");
            string choice = Console.ReadLine();

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

                case 2:
                    SeedOrCompost.CollectInput(farm);
                    break;

                case 3:
                    ChooseNaturalField.CollectInput(farm, new Wildflower());
                    break;

                case 4:
                    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);
            }
        }
Ejemplo n.º 14
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");

            Console.WriteLine();
            Console.WriteLine("Which seeds 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:
                    ChoosePlowedField.CollectInput(farm, new Sesame());
                    break;

                case 2:
                    SelectFieldType.CollectInput(farm);
                    break;

                case 3:
                    ChooseNaturalField.CollectInput(farm, new Wildflower());
                    break;

                default:
                    Console.WriteLine("Invlaid selection. Press any key to continute.");
                    string input7 = Console.ReadLine();
                    break;
                }
            }
            else
            {
                Console.WriteLine("Invlaid selection. Press any key to continute.");
                string input8 = Console.ReadLine();
            }
        }
Ejemplo n.º 15
0
        public static void AskHowManyPlants(Farm farm, string type)
        {
            Console.WriteLine("How many are you planting?");

            Console.Write("> ");
            string numberofPlants = Console.ReadLine();
            int    intofPlants    = Int32.Parse(numberofPlants);

            if (type == "sesame")
            {
                ChoosePlowedField.CollectInput(farm, intofPlants, type);
            }
            if (type == "sunflower")
            {
                ChoosePlowedOrNaturalField.CollectInput(farm, intofPlants, type);
            }
            if (type == "wildflower")
            {
                ChooseNaturalField.CollectInput(farm, intofPlants, type);
            }
        }
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower to natural field");
            Console.WriteLine("3. Sunflower to plowable field");
            Console.WriteLine("4. Wildflower");

            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":
                ChoosePlowedField.CollectInput(farm, new Sesame(), amount);
                break;

            case "2":
                ChooseNaturalField.CollectInput(farm, new Sunflower(), amount);
                break;

            case "3":
                ChoosePlowedField.CollectInput(farm, new Sunflower(), amount);
                break;

            case "4":
                ChooseNaturalField.CollectInput(farm, new Wildflower(), amount);
                break;

            default:
                Console.WriteLine($"{choice} Is not a valid input!");
                break;
            }
        }
Ejemplo n.º 17
0
        public static void CollectInput(Farm farm)
        {
            Console.Clear();
            Console.WriteLine("1. Seed");
            Console.WriteLine("2. Compost");
            Console.WriteLine("3. Return");
            Console.WriteLine();
            Console.WriteLine("What will these sunflowers be producing?");
            Console.Write("> ");
            string choice = Console.ReadLine();

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

                case 2:
                    ChooseNaturalField.CollectInput(farm, new Sunflower());
                    break;

                case 3:
                    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);
            }
        }
Ejemplo n.º 18
0
        // Have user select which field they would like to plant in and direct to that list

        public static void CollectInput(Farm farm, Sunflower sunflower)
        {
            Console.WriteLine("Where would you like to plant these seeds?");
            Console.WriteLine("1. Natural Field");
            Console.WriteLine("2. Plowed Field");
            Console.Write("> ");
            string choice = Console.ReadLine();

            switch (Int32.Parse(choice))
            {
            case 1:
                ChooseNaturalField.CollectInput(farm, sunflower);
                break;

            case 2:
                ChoosePlowedField.CollectInput(farm, sunflower);
                break;

            default:
                break;
            }
        }
        public static void CollectInput(Farm farm)
        {
            // print option of Plants to buy
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");

            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:
                ChoosePlowedField.CollectInput(farm, new Sesame());
                //prints confirmation of plowed field creation.
                break;

            default:
                break;

            case 2:
                DirectSunflowerSeeds.CollectInput(farm);
                //directs user to submenu selection

                break;

            case 3:
                ChooseNaturalField.CollectInput(farm, new Wildflower());
                //prints confirmation of natural field creation
                break;
            }
        }
Ejemplo n.º 20
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sunflower");
            Console.WriteLine("2. Sesame");
            Console.WriteLine("3. Wildflower");

            Console.WriteLine();

            Console.WriteLine("Choose which seed to purchase.");


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

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

                case 2:
                    ChoosePlowedField.CollectInput(farm, new Sesame());
                    break;

                case 3:
                    ChooseNaturalField.CollectInput(farm, new Wildflower());
                    break;
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 21
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. WildFlower");
            Console.WriteLine("2. Sesame");
            Console.WriteLine("3. Sunflower");

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

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

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

                case 2:
                    ChoosePlowedField.CollectInput(farm, new Sesame());
                    break;

                case 3:
                    ChooseDualField.CollectInput(farm, new Sunflower());
                    break;

                default:
                    break;
                }
            } catch {
                Console.WriteLine("Incorrect Input, please hit any key to return to main menu");
                // Console.ReadLine();
            }
        }
        private static void NewMethod(Farm farm, string input)
        {
            switch (Int32.Parse(input))
            {
            case 1:
                ChoosePlowedField.CollectInput(farm, new Sesame());
                break;

            case 2:
                ChooseNaturalField.CollectInput(farm, new Sunflower());
                break;

            case 3:
                ChoosePlowedField.CollectInput(farm, new Sunflower());
                break;

            case 4:
                ChooseNaturalField.CollectInput(farm, new Wildflower());
                break;

            default:
                break;
            }
        }
Ejemplo n.º 23
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Sunflower");
            Console.WriteLine("3. Wildflower");

            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.PlowedFields.Count != 0)
                    {
                        ChoosePlowedField.CollectInput(farm, new Sesame());
                    }
                    else
                    {
                        Console.WriteLine("You don't have any facilities for this plant!");
                        Console.WriteLine("Press any key to go to the Create Facility menu");
                        Console.ReadLine();
                        CreateFacility.CollectInput(farm);
                    }
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine("1. Seeds");
                    Console.WriteLine("2. Compost");
                    Console.WriteLine();
                    Console.WriteLine("What resource do you want from Sunflowers?");
                    Console.Write("> ");
                    int resourceChoice = Int32.Parse(Console.ReadLine());
                    if (resourceChoice == 1)
                    {
                        if (farm.PlowedFields.Count != 0)
                        {
                            ChoosePlowedField.CollectInput(farm, new Sunflower());
                        }
                        else
                        {
                            Console.WriteLine("You don't have any facilities for this plant!");
                            Console.WriteLine("Press any key to go to the Create Facility menu");
                            Console.ReadLine();
                            CreateFacility.CollectInput(farm);
                        }
                    }
                    else if (resourceChoice == 2)
                    {
                        if (farm.NaturalFields.Count != 0)
                        {
                            ChooseNaturalField.CollectInput(farm, new Sunflower());
                        }
                        else
                        {
                            Console.WriteLine("You don't have any facilities for this plant!");
                            Console.WriteLine("Press any key to go to the Create Facility menu");
                            Console.ReadLine();
                            CreateFacility.CollectInput(farm);
                        }
                    }
                    else
                    {
                        Console.WriteLine($"Invalid option: {resourceChoice}");
                        Console.WriteLine("Press any key to go back to main menu.");
                        Console.ReadLine();
                    }
                    break;

                case 3:
                    if (farm.NaturalFields.Count != 0)
                    {
                        ChooseNaturalField.CollectInput(farm, new Wildflower());
                    }
                    else
                    {
                        Console.WriteLine("You don't have any facilities for this plant!");
                        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, ISeedProducing plant)
        {
            Console.Clear();

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

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

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

            List <ISeedProducing> manyPlants = Enumerable.Repeat(plant, number).ToList();

            Console.Clear();

            for (int i = 0; i < farm.PlowedFields.Count; i++)
            {
                if (farm.PlowedFields[i].plantCount() == 1)
                {
                    Console.WriteLine($"{i + 1}. Plowed Field ({farm.PlowedFields[i].plantCount()} row of plants)");
                }
                else if (farm.PlowedFields[i].plantCount() < farm.PlowedFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Plowed Field ({farm.PlowedFields[i].plantCount()} rows of plants)");
                }
                // else
                // {
                //   Console.WriteLine($"{i + 1}. Plowed Field is full. ({farm.PlowedFields[i].plantCount()} rows of plants)");
                // }
            }
            Console.WriteLine();

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

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

            if (farm.PlowedFields[choice].plantCount() + manyPlants.Count() <= farm.PlowedFields[choice].Capacity)
            {
                farm.PlowedFields[choice].AddResource(manyPlants);
            }
            else
            {
                Console.Clear();
                Console.WriteLine($@"
~ I'm sorry! That facility can only hold ({farm.PlowedFields[0].Capacity}) plants ~

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

-----------------------((press enter to continue))----------------------
");
                Console.ReadLine();
                Console.Clear();
                // after user hits enter ask if they want to create a new field
                Console.WriteLine($@"
 _______________________________________________
| Would you like to create a new Plowed 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 plowedField and add it to the farm.
                // go to the ChoosePlowedField menu and pass the animal and farm
                case 1:
                    farm.AddPlowedField(new PlowedField());
                    Console.Clear();
                    Console.WriteLine("Success! One Plowed Field Added. Press enter to continue.");
                    Console.ReadLine();
                    ChoosePlowedField.CollectInput(farm, plant);
                    break;

                case 2:
                    break;
                }
            }
        }
Ejemplo n.º 25
0
        public static void CollectInput(Farm farm)
        {
            bool doOver;

            do
            {
                Console.WriteLine("1. Sesame");
                Console.WriteLine("2. Wildflower");
                Console.WriteLine("3. Sunflower");

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

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

                doOver = false;
                List <PlowedField>  availablePlowedFields  = FilteredPlowedFields(farm);
                List <NaturalField> availableNaturalFields = FilteredNaturalFields(farm);
                int parsedChoice;
                try
                {
                    parsedChoice = Int32.Parse(choice);
                }
                catch (Exception)
                {
                    parsedChoice = 0;
                }

                switch (parsedChoice)
                {
                case 1:
                    if (availablePlowedFields.Count == 0)
                    {
                        ChoosePlowedField.CollectInput(farm, new Sesame());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 2:
                    if (availableNaturalFields.Count == 0)
                    {
                        ChooseNaturalField.CollectInput(farm, new Wildflower());
                    }
                    else
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                    }
                    break;

                case 3:
                    if (availablePlowedFields.Count == 0 && availableNaturalFields.Count == 0)
                    {
                        Program.ShowMessage("No available facilities for this animal.");
                        break;
                    }
                    else
                    {
                        {
                            Console.Clear();
                            Program.DisplayBanner();
                            if (availableNaturalFields.Count > 0)
                            {
                                Console.WriteLine("1. Natural Field");
                            }
                            if (availablePlowedFields.Count > 0 && availableNaturalFields.Count > 0)
                            {
                                Console.WriteLine("2. Plowed Field");
                            }
                            if (availablePlowedFields.Count > 0 && availableNaturalFields.Count == 0)
                            {
                                Console.WriteLine("1. Plowed Field");
                            }
                            Console.WriteLine();
                            Console.WriteLine("Choose What type of Field to plant your Sunflowers in:");
                            Console.Write("> ");
                            string fieldType = Console.ReadLine();

                            switch (Int32.Parse(fieldType))
                            {
                            case 1:
                                ChooseNaturalField.CollectInput(farm, new Sunflower());
                                break;

                            case 2:
                                ChoosePlowedField.CollectInput(farm, new Sunflower());
                                break;

                            default:
                                break;
                            }
                            break;
                        }
                    }

                default:
                    Program.ShowMessage("Invalid selection.  Please choose again.");
                    doOver = true;
                    break;
                }
            } while (doOver);
        }
Ejemplo n.º 26
0
        public static void CollectInput(Farm farm)
        {
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Oat");
            Console.WriteLine("3. Sunflower");
            Console.WriteLine("4. Wildflower");
            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.PlowedFields.Count != 0)
                    {
                        ChoosePlowedField.CollectInput(farm, new Sesame());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for to plantin' your Sesames!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    }

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

                case 3:
                    Console.Clear();
                    if (farm.PlowedFields.Count != 0 && farm.NaturalFields.Count != 0)
                    {
                        Console.WriteLine("1. Plowed Field");
                        Console.WriteLine("2. Natural Field");
                        Console.WriteLine();
                        Console.WriteLine("What type of field do you want to plant your sunflowers?");
                    }
                    else if (farm.PlowedFields.Count != 0)
                    {
                        Console.WriteLine("1. Plowed Field");
                        Console.WriteLine();
                        Console.WriteLine("What type of field do you want to plant your sunflowers?");
                    }
                    else if (farm.NaturalFields.Count != 0)
                    {
                        Console.WriteLine("2. Natural Field");
                        Console.WriteLine();
                        Console.WriteLine("What type of field do you want to plant your sunflowers?");
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for to plantin' your Sunflowers!");
                        Console.WriteLine("\n\n");
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                        break;
                    };

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

                    if (input2 != "" && int.TryParse(input2, out int choice2))
                    {
                        switch (choice2)
                        {
                        case 1:
                            if (farm.PlowedFields.Count != 0)
                            {
                                ChoosePlowedField.CollectInput(farm, new Sunflower());
                            }
                            break;

                        case 2:
                            if (farm.NaturalFields.Count != 0)
                            {
                                ChooseNaturalfield.CollectInput(farm, new Sunflower());
                            }
                            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();
                    }
                    break;

                case 4:
                    if (farm.NaturalFields.Count != 0)
                    {
                        ChooseNaturalfield.CollectInput(farm, new Wildflower());
                        break;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("\n\n\n");
                        Console.WriteLine("There ain't no field for to plantin' your Wildflowers!");
                        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();
            }
        }
Ejemplo n.º 27
0
        public static void CollectInput(Farm farm)
        {
            // make a list of available plant classes
            List <Plant> AvailablePlants = new List <Plant>
            {
                new Sesame(), new WildFlower(), new SunFlower()
            };

            // make a menu that mirrors the list AvailablePlants
            Console.WriteLine("1. Sesame");
            Console.WriteLine("2. Wild Flower");
            Console.WriteLine("3. Sunflower");


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

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

            // make a new object of whatever type of plant the user chose
            dynamic chosenPlantType = Activator.CreateInstance(AvailablePlants[choice - 1].GetType());

            Console.WriteLine();
            Console.WriteLine("How many would you like to plant?");

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


            // Checks to see if the plant can be planted in BOTH Plowed AND Natural fields
            if (chosenPlantType is IAnyFieldDwelling)
            {
                if (qty != 1)
                {
                    List <IResource> plants = MakeListOfPlants(qty, (IResource)chosenPlantType);
                    ChooseBothField.CollectInput(farm, plants);
                }
                else
                {
                    ChooseBothField.CollectInput(farm, (IResource)chosenPlantType);
                }
            }
            else if (chosenPlantType is IPlowedFieldDwelling)
            {
                if (qty != 1)
                {
                    List <IResource> plants = MakeListOfPlants(qty, (IResource)chosenPlantType);
                    ChoosePlowedField.CollectInput(farm, plants);
                }
                else
                {
                    ChoosePlowedField.CollectInput(farm, (IResource)chosenPlantType);
                }
            }
            else
            {
                if (qty != 1)
                {
                    List <IResource> plants = MakeListOfPlants(qty, (IResource)chosenPlantType);
                    ChooseNaturalField.CollectInput(farm, plants);
                }
                else
                {
                    ChooseNaturalField.CollectInput(farm, (IResource)chosenPlantType);
                }
            }
        }