static void Main(string[] args)
        {
            // Create one of each container
            DiggerContainer  dirtBox    = new DiggerContainer();
            WalkerContainer  fencedArea = new WalkerContainer();
            SwimmerContainer aquarium   = new SwimmerContainer();
            FlierContainer   aviary     = new FlierContainer();

            // Create one of each animal, add to appropriate container
            aviary.ContainedAnimals.Add(new Parakeet("Simon the Parakeet"));

            dirtBox.ContainedAnimals.Add(new Earthworm("Jorah the Earthworm"));

            aquarium.ContainedAnimals.Add(new Terrapin("Calamy the Terrapin"));

            fencedArea.ContainedAnimals.Add(new TimberRattlesnake("Broderick the Timber Rattlesnake"));

            dirtBox.ContainedAnimals.Add(new Mouse("Sawyer the Mouse"));

            dirtBox.ContainedAnimals.Add(new Ant("Finn the Ant"));

            aviary.ContainedAnimals.Add(new Finch("Odin the Finch"));

            aquarium.ContainedAnimals.Add(new Betta("Thor the Betta"));

            fencedArea.ContainedAnimals.Add(new Copperhead("Martin the Copperhead"));

            dirtBox.ContainedAnimals.Add(new Gerbil("Gertie the Gerbil"));

            Console.WriteLine("Dirt Box contains:");
            dirtBox.ContainedAnimals.ForEach(animal => Console.WriteLine($" - {animal.Name}"));
            Console.WriteLine("Fenced Area contains:");
            fencedArea.ContainedAnimals.ForEach(animal => Console.WriteLine($" - {animal.Name}"));
            Console.WriteLine("Aquarium contains:");
            aquarium.ContainedAnimals.ForEach(animal => Console.WriteLine($" - {animal.Name}"));
            Console.WriteLine("Aviary contains:");
            aviary.ContainedAnimals.ForEach(animal => Console.WriteLine($" - {animal.Name}"));
        }
예제 #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();
        }