Esempio n. 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);
     }
 }
Esempio n. 2
0
        private int countThirstyPlants()
        {
            int numOfThirstyPlants = 0;

            foreach (var Plant in PlantsList)
            {
                if (Plant.NeedsWater())
                {
                    ++numOfThirstyPlants;
                }
            }
            return(numOfThirstyPlants);
        }
Esempio n. 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);
                }
            }
        }