Пример #1
0
        static void Main(string[] args)
        {
            //create an instance of each animal class
            Ants      ant   = new Ants();
            BettaFish betta = new BettaFish
            {
                MaximumDepth = 1
            };
            CopperheadSnakes copperhead = new CopperheadSnakes
            {
                MaximumDepth = 6
            };
            Earthworms worm     = new Earthworms();
            Finches    finch    = new Finches();
            Gerbils    gerbil   = new Gerbils();
            Mice       mice     = new Mice();
            Parakeets  parakeet = new Parakeets();
            Terrapins  terrapin = new Terrapins
            {
                MaximumDepth = 12
            };
            TimberRattlesnakes timber = new TimberRattlesnakes
            {
                MaximumDepth = 6
            };

            //add the animals to their respective container
            Diggers diggersContainer = new Diggers();

            diggersContainer.diggers.Add(ant);
            diggersContainer.diggers.Add(worm);
            diggersContainer.diggers.Add(gerbil);
            diggersContainer.diggers.Add(mice);

            Swimmers swimmersContainer = new Swimmers();

            swimmersContainer.swimmers.Add(betta);
            swimmersContainer.swimmers.Add(copperhead);
            swimmersContainer.swimmers.Add(terrapin);
            swimmersContainer.swimmers.Add(timber);

            Fliers fliersContainer = new Fliers();

            fliersContainer.fliers.Add(finch);
            fliersContainer.fliers.Add(parakeet);

            AboveGround aboveGroundContainer = new AboveGround();

            aboveGroundContainer.walkers.Add(ant);
            aboveGroundContainer.walkers.Add(gerbil);
            aboveGroundContainer.walkers.Add(mice);
            aboveGroundContainer.walkers.Add(terrapin);
            aboveGroundContainer.walkers.Add(finch);
            aboveGroundContainer.walkers.Add(parakeet);
            aboveGroundContainer.slitherers.Add(copperhead);
            aboveGroundContainer.slitherers.Add(timber);
        }
Пример #2
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();
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            Earthworms         earthworms         = new Earthworms();
            Ants               ants               = new Ants();
            Gerbils            gerbils            = new Gerbils();
            Finches            finches            = new Finches();
            Parakeets          parakeets          = new Parakeets();
            Terrapins          terrapins          = new Terrapins();
            TimberRattlesnakes timberRattlesnakes = new TimberRattlesnakes();
            Mice               mice               = new Mice();
            BettaFish          bettaFish          = new BettaFish();
            Copperheads        copperheads        = new Copperheads();


            List <ILiveInGround> InGroundAnimalsContainer = new List <ILiveInGround>()
            {
                earthworms, ants, gerbils
            };

            InGroundAnimalsContainer
            .ForEach(iga => iga.Dig());

            Console.WriteLine($"Time for the In Ground Animals to dig in the dirt of their Container");

            List <IFly> FlyingAnimalsContainer = new List <IFly>()
            {
                finches, parakeets
            };

            FlyingAnimalsContainer.ForEach(fac => fac.Fly());
            Console.WriteLine($"Time for the Flying Animals to fly into their cages");

            List <ISwim> SwimmingAnimalsContainer = new List <ISwim>()
            {
                bettaFish, terrapins
            };

            SwimmingAnimalsContainer.ForEach(sac => sac.Swim());
            Console.WriteLine($"All swimmers, please swim to your container. Thank you. ");

            List <IMoveOnGround> GroundMovingAnimalsContainer = new List <IMoveOnGround>()
            {
                gerbils, terrapins, mice, copperheads, timberRattlesnakes
            };

            GroundMovingAnimalsContainer.ForEach(sac => sac.GetMobile());
            Console.WriteLine($"Ground moving animals need to slither or walk or do whatever they do to get to their container.");
        }
Пример #4
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();
        }
Пример #5
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]}");
            }
        }