示例#1
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);
            }
        }
        public static void CollectInput(Farm farm, IPlowing plowedField)
        {
            Console.Clear();


            //This displays all grazing fields after purchasing animals
            for (int i = 0; i < farm.PlowedFields.Count; i++)
            {
                //Grazing field is an array.  + 1 will stop the list from starting at zero.
                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");
                }
            }

            // How can I output the type of animal chosen here?
            Console.WriteLine($"Plant 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.PlowedFields[choice - 1].AddResource(plowedField);


            /*
             *  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, IPlowing plant)
        {
            Utils.Clear();

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



            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.PlowedFields[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);
        }
示例#4
0
        public static void CollectInput(Farm farm, IPlowing row)
        {
            for (int i = 0; i < farm.PlowedFields.Count; i++)
            {
                foreach (var field in farm.PlowedFields)
                {
                    Console.WriteLine($"{1 + i++}. Plowed 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.PlowedFields[choice - 1].CurrentCapacity > 0)
            {
                farm.PlowedFields[choice - 1].AddResource(row);
            }
            else
            {
                Console.WriteLine("This Plowed Field is full.");
            }
        }
示例#5
0
        public static void CollectInput(Farm farm, IPlowing plant)
        {
            Console.Clear();

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

                        // Group Plowed Fields by their type to display their counts
                        List <IGrouping <string, IPlowing> > groupedPlowedFields = farm.PlowedFields[i].Plants.GroupBy(plnt => plnt.Type).ToList();

                        foreach (IGrouping <string, IPlowing> plnt in groupedPlowedFields)
                        {
                            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.PlowedFields[choice - 1].Plants.Count < farm.PlowedFields[choice - 1].Capacity)
                    {
                        farm.PlowedFields[choice - 1].AddResource(plant);
                    }
                    else if (farm.PlowedFields.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);
                }
            }
        }