Esempio n. 1
0
        /****************************************************************************************************
         * Test Excercise 4
         * Modify the EmydexFarmSystem.ReleaseAllAnimals() so that all animals are released (simply clear the collection )
         * Expose an event on the FarmSystem FarmEmpty which is invoked once all the animals are released
         * Subscribe to that event in the main to get the expected output
         *
         * Expected Test 4 Program Output
         *
         * Exercise 4: Press any key to free all animals
         * Cow has entered the farm
         * Hen has entered the farm
         * Horse has entered the farm
         * Sheep has entered the farm
         * Cow has left the farm
         * Hen has left the farm
         * Horse has left the farm
         * Sheep has left the farm
         * Emydex Farm is now empty
         ********************************************************************************************************************/
        private static void Excercise4()
        {
            //TODO : Apply OOP concepts and modify the code below to get the required output
            Console.WriteLine("Exercise 4: Press any key to free all animals");
            Console.ReadKey(true);
            var farm = new EmydexFarmSystem();
            Cow cow  = new Cow();

            farm.Enter(cow);

            Hen hen = new Hen();

            farm.Enter(hen);

            Horse horse = new Horse();

            farm.Enter(horse);

            Sheep sheep = new Sheep();

            farm.Enter(sheep);

            farm.ReleaseAllAnimals();
            Console.ReadKey(true);
        }