Пример #1
0
 public void displayState()
 {
     foreach (var Plant in PlantsList)
     {
         string state = "The " + Plant.Color + " " + Plant.Type;
         state += (Plant.NeedsWater() ? " needs water." : " doesn't need water.");
         Console.WriteLine(state);
     }
 }
Пример #2
0
        private int countThirstyPlants()
        {
            int numOfThirstyPlants = 0;

            foreach (var Plant in PlantsList)
            {
                if (Plant.NeedsWater())
                {
                    ++numOfThirstyPlants;
                }
            }
            return(numOfThirstyPlants);
        }
Пример #3
0
        public void Watering(double amountOfWater)
        {
            Console.WriteLine();
            Console.WriteLine("Watering with {0}", amountOfWater);
            int numOfThirstyPlants = countThirstyPlants();

            foreach (var Plant in PlantsList)
            {
                if (Plant.NeedsWater())
                {
                    Plant.Watering(amountOfWater / numOfThirstyPlants);
                }
            }
        }