Beispiel #1
0
/***************************************************************************************************************
 * Test Excercise 2
 * If you have completed the first test excercise, you can continue with the second one
 * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
 * Expected Test 2 Program Output
 *
 * Exercise 2 : Press any key to scare the animals in the farm
 *  Cow has entered the farm
 *  Hen has entered the farm
 *  Horse has entered the farm
 *  Sheep has entered the farm
 *  Cow says Moo!
 *  Hen says CLUCKAAAAAWWWWK!
 *  Horse says Neigh!
 *  Sheep says baa!
 *****************************************************************************************************************/
        private static void Excercise2()
        {
            //TODO : Apply OOP concepts and modify the code below to get the required output
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey();
            var farm = new EmydexFarmSystem();
            Cow cow  = new Cow();

            cow.Id = Guid.NewGuid().ToString();
            farm.Enter(cow);

            Hen hen = new Hen();

            hen.Id       = Guid.NewGuid().ToString();
            hen.NoOfLegs = 2;
            farm.Enter(hen);

            Horse horse = new Horse();

            horse.Id = Guid.NewGuid().ToString();
            farm.Enter(horse);

            Sheep sheep = new Sheep();

            sheep.Id = Guid.NewGuid().ToString();
            farm.Enter(sheep);

            farm.MakeNoise();
        }
Beispiel #2
0
/***************************************************************************************************************
 * Test Excercise 2
 * If you have completed the first test excercise, you can continue with the second one
 * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
 * Expected Test 2 Program Output
 *
 * Exercise 2 : Press any key to scare the animals in the farm
 *  Cow has entered the farm
 *  Hen has entered the farm
 *  Horse has entered the farm
 *  Sheep has entered the farm
 *  Cow says Moo!
 *  Hen says CLUCKAAAAAWWWWK!
 *  Horse says Neigh!
 *  Sheep says baa!
 *****************************************************************************************************************/
        private static void Excercise2()
        {
            //TODO : Apply OOP concepts and modify the code below to get the required output
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey();
            var farm = new EmydexFarmSystem();
            Cow cow  = new Cow();

            farm.Enter(cow); // can pass constructor too, ex. farm.Enter(new Cow());

            Hen hen = new Hen();

            farm.Enter(hen);

            Horse horse = new Horse();

            farm.Enter(horse);

            Sheep sheep = new Sheep();

            farm.Enter(sheep);

            farm.MakeNoise();
            Console.ReadKey();
        }
Beispiel #3
0
/***************************************************************************************************************
 * Test Excercise 2
 * If you have completed the first test excercise, you can continue with the second one
 * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
 * Expected Test 2 Program Output
 *
 * Exercise 2 : Press any key to scare the animals in the farm
 *  Cow has entered the farm
 *  Hen has entered the farm
 *  Horse has entered the farm
 *  Sheep has entered the farm
 *  Cow says Moo!
 *  Hen says CLUCKAAAAAWWWWK!
 *  Horse says Neigh!
 *  Sheep says baa!
 *****************************************************************************************************************/
        private static void Excercise2()
        {
            //TODO : Apply OOP concepts and modify the code below to get the required output
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey();
            var farm = new EmydexFarmSystem();

            AnimalsInFarm(farm);

            farm.MakeNoise();
            Console.ReadKey();
        }
Beispiel #4
0
        /***************************************************************************************************************
         * Test Excercise 2
         * If you have completed the first test excercise, you can continue with the second one
         * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
         * Expected Test 2 Program Output
         *
         * Exercise 2 : Press any key to scare the animals in the farm
         *  Cow has entered the farm
         *  Hen has entered the farm
         *  Horse has entered the farm
         *  Sheep has entered the farm
         *  Cow says Moo!
         *  Hen says CLUCKAAAAAWWWWK!
         *  Horse says Neigh!
         *  Sheep says baa!
         *****************************************************************************************************************/
        private static void Excercise2(EmydexFarmSystem farm)
        {
            //TODO : Apply OOP concepts and modify the code below to get the required output
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey();

            /*
             * Animals already entered farm. Just need to show animals in the Farm ;
             */
            farm.ShowFarmAnimals();

            farm.MakeNoise();
            Console.WriteLine();
            Console.ReadKey();
        }
Beispiel #5
0
        /***************************************************************************************************************
         * Test Exercise 2
         * If you have completed the first test excercise, you can continue with the second one
         * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
         * Expected Test 2 Program Output
         *
         * Exercise 2 : Press any key to scare the animals in the farm
         *  Cow has entered the farm
         *  Hen has entered the farm
         *  Horse has entered the farm
         *  Sheep has entered the farm
         *  Cow says Moo!
         *  Hen says CLUCKAAAAAWWWWK!
         *  Horse says Neigh!
         *  Sheep says baa!
         *****************************************************************************************************************/
        private static void Exercise2()
        {
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey(true);

            var farm = new EmydexFarmSystem();

            farm.EnterMob
            (
                CreateMob()
            );
            farm.MakeNoise();

            Console.WriteLine();
            Console.ReadKey(true);
        }
        /***************************************************************************************************************
         * Test Excercise 2
         * If you have completed the first test excercise, you can continue with the second one
         * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
         * Expected Test 2 Program Output
         *
         * Exercise 2 : Press any key to scare the animals in the farm
         *  Cow has entered the farm
         *  Hen has entered the farm
         *  Horse has entered the farm
         *  Sheep has entered the farm
         *  Cow says Moo!
         *  Hen says CLUCKAAAAAWWWWK!
         *  Horse says Neigh!
         *  Sheep says baa!
         *****************************************************************************************************************/
        private static void Excercise2()
        {
            //TODO : Apply OOP concepts and modify the code below to get the required output
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey();

            using (EmydexFarmSystem farm = new EmydexFarmSystem())
            {
                //List<IAnimal> animals = new List<IAnimal>() { new Cow(), new Hen(), new Horse(), new Sheep() };
                animals.ForEach(animal =>
                {
                    // Assign an Id to each animal,
                    // the NoOfLegs can be predefined within the class as they do not change, but still can be changed setting the property
                    animal.Id = Guid.NewGuid().ToString();
                    // Enter the farm
                    farm.Enter(animal);
                });
                farm.MakeNoise();
            }
            Console.ReadKey();
        }
Beispiel #7
0
/***************************************************************************************************************
 * Test Excercise 2
 * If you have completed the first test excercise, you can continue with the second one
 * Modify the program and EmydexFarmSystem.MakeNoise() method to get the below output
 * Expected Test 2 Program Output
 *
 * Exercise 2 : Press any key to scare the animals in the farm
 *  Cow has entered the farm
 *  Hen has entered the farm
 *  Horse has entered the farm
 *  Sheep has entered the farm
 *  Cow says Moo!
 *  Hen says CLUCKAAAAAWWWWK!
 *  Horse says Neigh!
 *  Sheep says baa!
 *****************************************************************************************************************/
        private static void Excercise2()
        {
            Console.WriteLine("Exercise 2 : Press any key to scare the animals in the farm");
            Console.ReadKey();

            var farm = new EmydexFarmSystem();

            var allAnimals = new List <IAnimal>()
            {
                { new Cow() },
                { new Hen() },
                { new Horse() },
                { new Sheep() }
            };

            farm.Enter(allAnimals);

            farm.MakeNoise();

            Console.ReadKey();
        }