Пример #1
0
        static void Main(string[] args)
        {
            var ant         = new Ant();
            var copperhead  = new Copperhead();
            var betta       = new BettaFish();
            var earthworm   = new Earthwoorm();
            var finch       = new Finch();
            var gerbil      = new Gerbil();
            var mouse       = new Mouse();
            var parakeet    = new Parakeet();
            var rattlesnake = new Rattlesnake();
            var terrapin    = new Terrapin();

            var Diggers = new DiggerCOntainer();
            var Fliers  = new FlyerCOntainer();
            var Swimers = new SwimmerCOntainer();
            var Walkers = new WalkerCOntainer();

            Diggers.Diggers.Add(ant);
            Diggers.Diggers.Add(earthworm);
            Fliers.Fliers.Add(finch);
            Fliers.Fliers.Add(parakeet);
            Swimers.Swimmers.Add(betta);
            Swimers.Swimmers.Add(terrapin);
            Walkers.Walkers.Add(copperhead);
            Walkers.Walkers.Add(gerbil);
            Walkers.Walkers.Add(mouse);
            Walkers.Walkers.Add(rattlesnake);
            Console.WriteLine("DIGGERS");
            foreach (var digger in Diggers.Diggers)
            {
                digger.Dig();
            }
            Console.WriteLine("FLIERS");
            foreach (var flyer in Fliers.Fliers)
            {
                flyer.Fly();
            }
            Console.WriteLine("WALKERS");
            foreach (var walker in Walkers.Walkers)
            {
                walker.Walk();
            }
            Console.WriteLine("SWIMMERS");
            foreach (var swimmer in Swimers.Swimmers)
            {
                swimmer.Swim();
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Parakeet bob = new Parakeet()
            {
                Name            = "Bob",
                Color           = "lime",
                Species         = "Parakeet",
                maximumDistance = 20
            };



            Ant joe = new Ant()
            {
                Name            = "Joe",
                Color           = "red",
                Species         = "Fire Ant",
                landSpeed       = 1,
                requiredBedding = "dirt"
            };

            Earthworm jim = new Earthworm()
            {
                Name            = "Jim",
                Color           = "reddish brown",
                Species         = "Nightcrawler",
                requiredBedding = "dirt"
            };

            Finch job = new Finch()
            {
                Name            = "Job",
                Color           = "grey",
                Species         = "House Finch",
                maximumDistance = 20
            };

            Gerbil jack = new Gerbil()
            {
                Name            = "Jack",
                Color           = "beige",
                Species         = "Gerbil",
                landSpeed       = 1,
                requiredBedding = "wood shavings"
            };

            Mouse minnie = new Mouse()
            {
                Name            = "Minnie",
                Color           = "grey",
                Species         = "Grey Mouse",
                landSpeed       = 5,
                requiredBedding = "wood shavings"
            };

            TimberRattlesnake sly = new TimberRattlesnake()
            {
                Name      = "Sly",
                Color     = "brown",
                Species   = "Timber Rattlesnake",
                landSpeed = 10,
            };

            Copperhead lucifer = new Copperhead
            {
                Name      = "Lucifer",
                Color     = "beige",
                Species   = "Copperhead Snake",
                landSpeed = 10,
            };

            Terrapin mary = new Terrapin {
                Name      = "Mary",
                Color     = "green",
                Species   = "Terrapin",
                landSpeed = 1,
            };

            BettaFish alpha = new BettaFish {
                Name         = "Alpha",
                Color        = "blue",
                Species      = "Betta Fish",
                maximumDepth = 50,
            };

            FlierContainer   flierStorage   = new FlierContainer();
            DiggerContainer  diggerStorage  = new DiggerContainer();
            SwimmerContainer swimmerStorage = new SwimmerContainer();
            WalkerContainer  walkerStorage  = new WalkerContainer();

            flierStorage.Fliers.Add(bob);
            flierStorage.Fliers.Add(job);
            diggerStorage.Diggers.Add(joe);
            diggerStorage.Diggers.Add(jim);
            diggerStorage.Diggers.Add(jack);
            diggerStorage.Diggers.Add(minnie);
            swimmerStorage.Swimmers.Add(alpha);
            walkerStorage.Walkers.Add(sly);
            walkerStorage.Walkers.Add(lucifer);
            walkerStorage.Walkers.Add(mary);

            Console.WriteLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            System.Console.WriteLine();
            var ant = new Ant()
            {
                name = "Henry"
            };

            ant.Move();

            Console.WriteLine();
            var bettaFish = new BettaFish("Steve", "Blue");

            bettaFish.Move();

            Console.WriteLine();
            var copperhead = new Copperhead()
            {
                name = "Carl"
            };

            copperhead.Move();

            Console.WriteLine();
            var earthworm = new Earthworm();

            earthworm.Move();

            Console.WriteLine();
            var finch = new Finch("Heath", "blue");

            finch.Move();

            Console.WriteLine();
            var gerbil = new Gerbil()
            {
                name = "Germaine"
            };

            gerbil.Move();

            Console.WriteLine();
            var mouse = new Mouse()
            {
                name = "Jerry"
            };

            mouse.Move();

            Console.WriteLine();
            var parakeet = new Parakeet("Tim", "yellow");

            parakeet.Move();

            Console.WriteLine();
            var rattlesnake = new Rattlesnake()
            {
                name = "Rick"
            };

            rattlesnake.Move();

            Console.WriteLine();
            var terrapin = new Terrapin()
            {
                name = "Shelldon"
            };

            terrapin.Move();

            System.Console.WriteLine();
            var groundAnimals = new List <IWalker>()
            {
                ant, mouse, terrapin, gerbil, rattlesnake, copperhead
            };

            System.Console.WriteLine("Land animals:");
            foreach (var animal in groundAnimals)
            {
                System.Console.WriteLine($"{animal.name} the {animal.GetType().ToString().Split(".")[1]}");
            }

            System.Console.WriteLine();
            var aquaticAnimals = new List <ISwimmer>()
            {
                bettaFish
            };

            System.Console.WriteLine("Aquatic animals:");
            foreach (var animal in aquaticAnimals)
            {
                System.Console.WriteLine($"{animal.name} the {animal.GetType().ToString().Split(".")[1]}");
            }

            System.Console.WriteLine();
            var flyingAnimals = new List <IFlier>()
            {
                finch, parakeet
            };

            System.Console.WriteLine("Flying animals:");
            foreach (var animal in flyingAnimals)
            {
                System.Console.WriteLine($"{animal.name} the {animal.GetType().ToString().Split(".")[1]}");
            }
        }