Ejemplo n.º 1
0
        // loop through the natural fields and list options for fields to plant
        public static void CollectInput(Farm farm, IComposting seed)
        {
            Utils.Clear();
            for (int i = 0; i < farm.NaturalFields.Count; i++)
            {
                Console.WriteLine($"{i + 1}. Natural Field has {farm.NaturalFields[i]._seeds.Count} Plants");

                var seedreport = from naturalseeds in farm.NaturalFields[i]._seeds
                                 group naturalseeds by naturalseeds.Type into seedgroup
                                 select  new Dictionary <string, int>()
                {
                    { seedgroup.Key, seedgroup.Count() }
                };


                foreach (Dictionary <string, int> naturalseeds in seedreport)
                {
                    foreach (KeyValuePair <string, int> seedgroup in naturalseeds)
                    {
                        Console.WriteLine($"This field has {seedgroup.Value} {seedgroup.Key}s");
                    }
                }
                ;
            }
            Console.WriteLine($"Place the Seed Where?");
            Console.WriteLine("> ");
            int choice = Int32.Parse(Console.ReadLine());

            farm.NaturalFields[choice - 1].AddResource(seed);
        }
        public static void CollectInput(Farm farm, IComposting seed)
        {
            Console.Clear();

            var fieldsWithSpace = farm.NaturalFields.Where(field => field.AvailableSpots > 0).ToList();

            if (fieldsWithSpace.Count < 1)
            {
                Console.WriteLine("There are no Natural Fields with space available");
                Console.WriteLine("Press any button to continue.");
                Console.ReadLine();
                Console.Clear();
                Program.DisplayBanner();
                PurchaseSeed.CollectInput(farm);
            }
            for (int i = 0; i < fieldsWithSpace.Count; i++)
            {
                Console.WriteLine($"{i + 1}. {fieldsWithSpace[i].Name} - Current Plants {fieldsWithSpace[i].currentPlants} | Available Rows: {fieldsWithSpace[i].AvailableSpots}");
                fieldsWithSpace[i].ListByType();
            }

            Console.WriteLine();

            Console.WriteLine($"Place the row of seeds where?");

            Console.Write("> ");

            try
            {
                int choice = Int32.Parse(Console.ReadLine()) - 1;

                farm.NaturalFields[choice].AddResource(seed);
            }
            catch (Exception)
            {
                Program.ShowMessage("Invalid Input");
            }
        }
Ejemplo n.º 3
0
 public void AddToHopper(IComposting resourceToAdd)
 {
     _hopper.Add(resourceToAdd);
 }