static void Main(string[] args)
        {
            //
            // OLD MACDONALD
            //

            Cow sleepy = new Cow("Sleepy");

            sleepy.Sleep();
            Cat cat = new Cat("Cosmic Creepers");

            cat.Sleep();
            Jersey jersey = new Jersey();
            Cat    felix  = new Cat("Felix");

            Console.WriteLine(sleepy.Eat());
            Console.WriteLine(cat.Eat());
            ISingable[] singables = new ISingable[]
            {
                new Cow("Henry"), new Chicken(), new Pig(), new Tractor(), new Cow("Earl"), sleepy, cat, jersey, felix
            };

            ((FarmAnimal)singables[2]).Sleep();
            foreach (ISingable singable in singables)
            {
                Console.WriteLine("Old MacDonald had a farm, ee ay ee ay oh!");
                Console.WriteLine("And on his farm he had a " + singable.Name + ", ee ay ee ay oh!");
                Console.WriteLine("With a " + singable.Sound + " " + singable.Sound + " here");
                Console.WriteLine("And a " + singable.Sound + " " + singable.Sound + " there");
                Console.WriteLine("Here a " + singable.Sound + " there a " + singable.Sound + " everywhere a " + singable.Sound + " " + singable.Sound);
                Console.WriteLine();
            }

            ISellable[] sellables = new ISellable[]
            {
                new Cow("Henry"), new Pig(), new Egg()
            };

            foreach (ISellable sellable in sellables)
            {
                Console.WriteLine("Step right up and get your " + sellable.Name);
                Console.WriteLine("Only $" + sellable.Price);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Pig Babe = new Pig();

            Babe.sayName("Babe");
            Babe.Speak();
            Babe.Eat();
            Babe.benefit();

            Horse Ed = new Horse();

            Ed.sayName("Mr. Ed to you!");
            Ed.Speak();
            Ed.Eat();
            Ed.benefit();

            Cow Isis = new Cow();

            Isis.sayName("Isis the Goddess");
            Isis.Speak();
            Isis.Eat();
            Isis.benefit();

            Rabbit bugs = new Rabbit();

            bugs.sayName("Sir Bugguswald Bunny");
            bugs.Speak();
            bugs.Eat();
            bugs.benefit();

            Horse SB = new Horse();

            SB.sayName("SeaBiscuit the prize horse!!");
            SB.Speak();
            SB.Eat();
            SB.benefit();

            Rabbit PR = new Rabbit();

            PR.sayName("The young Peter Rabbit");
            PR.Speak();
            PR.Eat();
            PR.benefit();
        }
Beispiel #3
0
        static public void RunPart2()
        {
            Dog dog = new Dog();

            dog.Speak();
            dog.Run();
            dog.Eat();

            Cat cat = new Cat();

            cat.Speak();
            cat.Run();
            cat.Eat();

            Cow cow = new Cow();

            cow.Speak();
            cow.Run();
            cow.Eat();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Pig Bacon = new Pig();

            Bacon.name = "Bacon";
            Bacon.printbase();
            Bacon.Speak();
            Bacon.Eat();
            Bacon.poop();

            Console.WriteLine();

            Cow Henry = new Cow();

            Henry.name = "Henry";
            Henry.printbase();
            Henry.Speak();
            Henry.Eat();
            Henry.poop();

            Console.WriteLine();

            Horse Stephen = new Horse();

            Stephen.name = "Stephen";
            Stephen.printbase();
            Stephen.Speak();
            Stephen.Eat();
            Stephen.poop();


            Console.WriteLine();

            Chicken Rex = new Chicken();

            Rex.name = "Rex";
            Rex.printbase();
            Rex.Speak();
            Rex.Eat();
            Rex.poop();
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            var address = new AddressBookBuilder();

            address.ActualNumber = 1830;
            address.StreetName   = "Meridain Ave";
            address.LocationName = "South Beach Apt";
            Console.WriteLine(address);
            //
            var oldBoat = new Boat("Trirton", "Outboard Engine type");

            oldBoat.Buy("Frank");
            Console.WriteLine(oldBoat);
            //

            /*var horse = new Animal {Name = "Mr. Ed", FavoriteFood = "Grass",Greeting = "Hello Wilbur"}; //No constructor in class so we set out here.
             * horse.Speak();
             * horse.Eat();*/
            //
            var horse2 = new Horse {
                Name = "Clippity Clop"
            };

            horse2.Speak();
            horse2.Eat();
            horse2.ShoeMyHorse();
            //
            var Betsy = new Cow {
                Name = "Betsy"
            };

            Betsy.Speak();
            Betsy.Eat();
            Betsy.GiveMilk();
            //
            var lancelot  = new Knight();
            var legolas   = new Archer();
            var merlin    = new Wizard();
            var sgtPatton = new RifleSoldier();
            var pvtGump   = new GrenadierSoldier();
            //
            var modernArmy = new List <Soldier>();

            modernArmy.Add(sgtPatton);
            modernArmy.Add(pvtGump);

            modernArmy.ForEach(fighter => fighter.Attack());
            //
            var army = new List <Warrior>();

            army.Add(lancelot);
            army.Add(legolas);
            army.Add(merlin);

            army.ForEach(fighter => fighter.Attack());
            //
            var pegasus1 = new Pegasus(40, 30);

            pegasus1.IncreaseSpeed(20);
            pegasus1.DecreaseSpeed(10);
            pegasus1.FlapWings(10);
            pegasus1.Glide(5);
            Console.WriteLine(pegasus1);
            //
            var car1 = new Car("Volks", "GTI", 210, 25000);

            car1.IncreaseHP(50);
            car1.DecreaseHP(20);
            car1.IncreaseValue(6000);
            car1.DecreaseValue(1000);
            Console.WriteLine(car1);
            //
            var sportsCar1 = new SportsCar("Porsche", "911", 350, 90000);

            sportsCar1.IncreaseHP(50);
            sportsCar1.CustomParts.IncreaseValue(20);


            sportsCar1.IncreaseHpToSportCarLevels();
            Console.WriteLine(sportsCar1);
            //

            Console.ReadLine();
        }
Beispiel #6
0
        public void CowCanInheritEat()
        {
            Cow cow = new Cow();

            Assert.Equal("I like to eat grass!", cow.Eat());
        }