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); }
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."); }