Exemplo n.º 1
0
        public void GetAnimals(GrazingField grazingField)
        {
            List <IResource> animals = new List <IResource>();

            foreach (IGrazing animal in _animals)
            {
                animals.Add((IResource)animal);
            }
            var groupedAnimals = animals.GroupBy(a => a.Type).Select(a => new { type = a.Key, number = a.Count() }).ToList();
            int counter        = 0;

            foreach (var animal in groupedAnimals)
            {
                counter++;
                Console.WriteLine($"{counter}. {animal.type} Count: {animal.number}");
            }
            Console.WriteLine("Which resource should we process?");
            string choice = Console.ReadLine();

            if (int.Parse(choice) <= groupedAnimals.Count())
            {
                Console.WriteLine($"How many cows should be processed?");
                string quantity = Console.ReadLine();
                if (int.Parse(quantity) <= groupedAnimals[int.Parse(choice) - 1].number && int.Parse(quantity) <= 7)
                {
                    for (int i = 0; i < int.Parse(quantity); i++)
                    {
                        _animals.Remove(_animals[0]);
                        Meat += 18.25;
                    }
                    Console.WriteLine();
                    Console.WriteLine($"{int.Parse(quantity) * 18.25}kg of cow meat have been produced");
                    Console.ReadLine();
                }
                else if (int.Parse(quantity) <= groupedAnimals[int.Parse(choice) - 1].number)
                {
                    Console.WriteLine("Equipment can only handle up to 7 cows");
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                }
            }
        }
        // internal object GetChickenFeeds()
        // {
        //     throw new NotImplementedException();
        // }

        public void AddGrazingField(GrazingField field)
        {
            GrazingFields.Add(field);
        }