public static void CollectInput(Farm farm, INatural plant)
        {
            Utils.Clear();

            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Natural Field");
            }

            Console.WriteLine();

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

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

            farm.NaturalFields[choice].AddResource(plant);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
        public static void CollectInput(Farm farm, INatural naturalField)
        {
            Console.Clear();


            //This displays all grazing fields after purchasing animals
            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                //Grazing field is an array.  + 1 will stop the list from starting at zero.
                if (farm.NaturalFields[i].rowsOfPlants > farm.NaturalFields[i].plants.Count)
                {
                    Console.WriteLine($"{i + 1}.Natural Fields : Contains {farm.NaturalFields[i].plants.Count * 6} Plants with {farm.NaturalFields[i].rowsOfPlants - farm.NaturalFields[i].plants.Count} Rows Available");
                }
            }

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

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

            //-1 will set the choice back to the GrazinFields actual array index not the displayed "list" value.4

            farm.NaturalFields[choice - 1].AddResource(naturalField);


            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
Example #3
0
        public static void CollectInput(Farm farm, INatural taco)
        {
            Console.Clear();

            for (int i = 0; i < farm.PlowedFields.Count; i++)
            {
                if (farm.PlowedFields[i].rowsOfPlants > farm.PlowedFields[i].plants.Count)
                {
                    Console.WriteLine($"{i + 1}. Plowed Field : Contains {farm.PlowedFields[i].plants.Count * 5} Plants with {farm.PlowedFields[i].rowsOfPlants - farm.PlowedFields[i].plants.Count} Rows Available");
                }
            }


            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                if (farm.NaturalFields[i].rowsOfPlants > farm.NaturalFields[i].plants.Count)
                {
                    Console.WriteLine($"{i + 1 + farm.PlowedFields.Count}. Natural Field : Contains {farm.NaturalFields[i].plants.Count * 6} Plants with {farm.NaturalFields[i].rowsOfPlants - farm.NaturalFields[i].plants.Count} Rows Available");
                }
            }
            Console.WriteLine($"Plant seeds where?");
            Console.Write("> ");

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

            if (choice > farm.PlowedFields.Count)
            {
                farm.NaturalFields[choice - 1 - farm.PlowedFields.Count].AddResource(taco);
            }
            else
            {
                IPlowing resource = (IPlowing)taco;
                farm.PlowedFields[choice - 1].AddResource(resource);
            }
        }
Example #4
0
        public static void CollectInput(Farm farm, INatural plant)
        {
            Console.Clear();


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

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

            numberOfPlants.Clear();
            for (int i = 0; i < input; i++)
            {
                numberOfPlants.Add(plant);
            }


            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                if (farm.NaturalFields[i].Flowers.Count < farm.NaturalFields[i].Capacity)
                {
                    NaturalField specificField = farm.NaturalFields[i];
                    Console.WriteLine($"{i + 1}. {specificField}");
                }
            }

            Console.WriteLine();

            Console.WriteLine($"Where would you like to plant the {plant}?");

            Console.Write("> ");
            try
            {
                int choice = Int32.Parse(Console.ReadLine()) - 1;
                farm.NaturalFields[choice].AddResources(numberOfPlants);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(ex);
            }


            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<INatural>(plant, choice);
        }
        public static void CollectInput(Farm farm, INatural plant)
        {
            Console.Clear();
            List <NaturalField> capacityList = farm.NaturalFields.Where(thingy => thingy.NumberOfPlants < thingy.Capacity).ToList();

            if (capacityList.Count == 0)
            {
                Console.WriteLine("All natural fields are at capacity or you have not created a natural field. Please create a new natural field.");
                Console.WriteLine("Please press enter to return to the main menu.");
                Console.ReadLine();
                return;
            }
            else
            {
                for (int i = 0; i < capacityList.Count; i++)
                {
                    if (capacityList[i].NumberOfPlants < capacityList[i].Capacity)
                    {
                        // if the grazing field is not over capacity, display and chose it
                        Console.WriteLine($"Number of plants in natural field {i + 1}: {capacityList[i].NumberOfPlants}");
                    }
                }
            }


            Console.WriteLine();

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

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

            Console.WriteLine("You've planted a seed!");
            Thread.Sleep(1000);

            farm.NaturalFields[choice - 1].AddResource(plant);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
        public static void CollectInput(Farm farm, INatural plant)
        {
            Utils.Clear();

            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                if (farm.NaturalFields[i].PlantCount() < farm.NaturalFields[i].Capacity)
                {
                    Console.WriteLine($"{i + 1}. Natural Field");
                    Console.WriteLine($"\t This field has {farm.NaturalFields[i].PlantCount()} plants currently!\n");
                    var SunflowerCount = 0;
                    SunflowerCount = farm.NaturalFields[i].NaturalPlantList()
                                     .Where(plantType => plantType.Type == "Sunflower")
                                     .Count();
                    Console.WriteLine($"\t \t There are {SunflowerCount} rows of Sunflowers!");
                    var WildflowerCount = 0;
                    WildflowerCount = farm.NaturalFields[i].NaturalPlantList()
                                      .Where(plantType => plantType.Type == "Wildflower")
                                      .Count();
                    Console.WriteLine($"\t \t There are {WildflowerCount} rows of Wildflowers!");
                }
            }

            {
            }

            Console.WriteLine();

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

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

            farm.NaturalFields[choice - 1].AddResource(plant);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IPlowing>(plant, choice);
        }
        public static void CollectInput(Farm farm, INatural seed)
        {
            Utils.Clear();

            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                if (farm.NaturalFields[i].seedCount != farm.NaturalFields[i].Capacity)
                {
                    var sunflowerCount  = 0;
                    var wildflowerCount = 0;

                    Console.WriteLine($"{i + 1}. {farm.NaturalFields[i].ToString()} Max Capacity: {farm.NaturalFields[i].Capacity}");

                    wildflowerCount = farm.NaturalFields[i]._seeds
                                      .Where(plant => plant.Type == "Wildflower")
                                      .Count();
                    Console.WriteLine($"Wildflower: {wildflowerCount}\n");

                    sunflowerCount = farm.NaturalFields[i]._seeds
                                     .Where(plant => plant.Type == "Sunflower")
                                     .Count();
                    Console.WriteLine($"Sunflower: {sunflowerCount}\n");
                }
            }

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

            Console.WriteLine($"Place the plant where?");
            Console.Write("> ");
            int choice = Int32.Parse(Console.ReadLine()) - 1;

            farm.NaturalFields[choice].AddResource(seed);

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }
        public static void CollectInput(Farm farm, INatural row)
        {
            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                foreach (var field in farm.NaturalFields)
                {
                    Console.WriteLine($"{1 + i++}. Natural field, currently has {field.Capacity - field.CurrentCapacity} seeds");
                    if (field._rows.Count > 0)
                    {
                        foreach (var singleSeed in field._rows.GroupBy(a => a.GetType().Name))
                        {
                            Console.Write($" - Contains {singleSeed.Count()} {singleSeed.Key}");
                            if (singleSeed.Count() > 1)
                            {
                                Console.Write("s" + "\n");
                            }
                            else
                            {
                                Console.Write("\n");
                            }
                        }
                    }
                }
            }

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

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

            if (farm.NaturalFields[choice - 1].CurrentCapacity > 0)
            {
                farm.NaturalFields[choice - 1].AddResource(row);
            }
            else
            {
                Console.WriteLine("This natural field is full.");
            }
        }
Example #9
0
        public static void CollectInput(Farm farm, INatural plant)
        {
            Console.Clear();

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

                        // Group Natural Fields by their type to display their counts
                        List <IGrouping <string, INatural> > groupedNaturalFields = farm.NaturalFields[i].Plants.GroupBy(plnt => plnt.Type).ToList();

                        foreach (IGrouping <string, INatural> plnt in groupedNaturalFields)
                        {
                            Console.WriteLine($"{plnt.Key}: {plnt.Count()} rows");
                        }
                        Console.WriteLine("=================================================");
                    }
                }

                Console.WriteLine();

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

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


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

            List <IFacility <INatural> > openNaturalFields = new List <IFacility <INatural> >();

            var sortedNaturalFields = farm.NaturalFields.Where(naturalField => (naturalField.Capacity - 1) >= naturalField.CurrentStock()).ToList();

            for (int i = 0; i < sortedNaturalFields.Count; i++)
            {
                if ((sortedNaturalFields[i].Capacity - 1) >=
                    sortedNaturalFields[i].CurrentStock())
                {
                    openNaturalFields.Add(sortedNaturalFields[i]);
                    Console.WriteLine($"{i + 1}. Natural Field (Current Stock: {sortedNaturalFields[i].CurrentStock()})");

                    sortedNaturalFields[i].ShowPlantsByType();
                }
            }

            Console.WriteLine();

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

            // if (openNaturalFields.Count > 0)
            // {

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

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

            //     if (plant is INatural)
            //     {
            //         sortedNaturalFields[choice - 1].AddResource(plant);
            //     }
            //     else
            //     {
            //         // Console.Clear();
            //         Console.WriteLine("Please select another facility");
            //         for (int i = 0; i < farm.NaturalFields.Count; i++)
            //         {
            //             Console.WriteLine($"{i + 1}. Natural Field");
            //         }
            //     }
            // }
            else
            {
                Console.WriteLine("There are no matching facilities available. Please create one first.");
                Thread.Sleep(2000);
            }

            /*
             *  Couldn't get this to work. Can you?
             *  Stretch goal. Only if the app is fully functional.
             */
            // farm.PurchaseResource<IGrazing>(animal, choice);
        }