static void Main(string[] args)
        {
            Parakeet parakeet = new Parakeet()
            {
                MaximumHeight = 40
            };

            Earthworm worm = new Earthworm()
            {
                MaximumDepth            = 5,
                AvgDistanceWalkedPerDay = 0
            };

            Terrapin terrapin = new Terrapin()
            {
                MaximumDepth            = 40,
                AvgDistanceWalkedPerDay = 1
            };

            TimberRattlesnake rattlesnake = new TimberRattlesnake()
            {
                MaximumDepth            = 1,
                AvgDistanceWalkedPerDay = 2
            };

            Mouse mouse = new Mouse()
            {
                MaximumDepth            = 2,
                AvgDistanceWalkedPerDay = 5
            };

            Ant ant = new Ant()
            {
                MaximumDepth            = 4,
                AvgDistanceWalkedPerDay = 3
            };

            Finch finch = new Finch()
            {
                MaximumHeight = 40
            };

            BetaFish fish = new BetaFish()
            {
                MaximumDepth = 30
            };

            CopperheadSnake copperhead = new CopperheadSnake()
            {
                MaximumDepth            = 1,
                AvgDistanceWalkedPerDay = 5
            };

            Gerbil gerbil = new Gerbil()
            {
                MaximumDepth            = 1,
                AvgDistanceWalkedPerDay = 10
            };

            AnimalLists seperated = new AnimalLists()
            {
                LandAnimals = new List <IWalking>()
                {
                    copperhead, rattlesnake
                },
                AnimalsOfTheSky = new List <IFlying>()
                {
                    finch, parakeet
                },
                AnimalsThatDig = new List <IDigging>()
                {
                    ant, gerbil, mouse, worm
                },
                SeaAnimals = new List <ISwimming>()
                {
                    fish, terrapin
                }
            };

            Console.WriteLine("List of Land Animals: ");


            foreach (IWalking landAnimal in seperated.LandAnimals)
            {
                Console.WriteLine(landAnimal);
            }

            Console.WriteLine();
            Console.WriteLine("List of Flying Animals: ");

            foreach (IFlying skyAnimal in seperated.AnimalsOfTheSky)
            {
                Console.WriteLine(skyAnimal);
            }

            Console.WriteLine();
            Console.WriteLine("List of Digging Animals: ");

            foreach (IDigging diggingAnimal in seperated.AnimalsThatDig)
            {
                Console.WriteLine(diggingAnimal);
            }

            Console.WriteLine();
            Console.WriteLine("List of Sea Animals: ");

            foreach (ISwimming seaAnimal in seperated.SeaAnimals)
            {
                Console.WriteLine(seaAnimal);
            }


            Console.WriteLine();
        }
示例#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]}");
            }
        }