static void Main(string[] args) { Ant redAnt = new Ant(); BettaFish blackBettaFish = new BettaFish(); CopperheadSnake whiteSnake = new CopperheadSnake(); Earthworm pinkEarthworm = new Earthworm(); Finch greyFinch = new Finch(); Gerbil brownGerbil = new Gerbil(); Mouse whiteMouse = new Mouse(); Parakeet blueParakeet = new Parakeet(); Terrapin greenTerrapin = new Terrapin(); TimberRattlesnake brownTimberRattlesnake = new TimberRattlesnake(); Animals MyAnimals = new Animals(); List <IWalking> GroundHabitat = MyAnimals.MakeGroundHabitat(); List <IFlying> AirHabitat = MyAnimals.MakeAirHabitat(); List <IDigging> UndergroundHabitat = MyAnimals.MakeUndergroundHabitat(); List <ISwimming> WaterHabitat = MyAnimals.MakeWaterHabitat(); }
static void Main(string[] args) { Ant ant = new Ant(); BettaFish bettaFish = new BettaFish(); CopperheadSnake copperhead = new CopperheadSnake(); Earthworm earthworm = new Earthworm(); Finch finch = new Finch(); Gerbil gerbil = new Gerbil(); Mouse mouse = new Mouse(); Parakeet parakeet = new Parakeet(); Rattlesnake rattlesnake = new Rattlesnake(); Terrapin terrapin = new Terrapin(); AnimalsThatDig diggers = new AnimalsThatDig(); diggers.AnimalsThatDigList.Add(ant); diggers.AnimalsThatDigList.Add(earthworm); AnimalsThatFly fliers = new AnimalsThatFly(); fliers.AnimalsThatFlyList.Add(parakeet); fliers.AnimalsThatFlyList.Add(finch); AnimalsThatMoveOnGround movers = new AnimalsThatMoveOnGround(); movers.AnimalsThatMoveOnGroundList.Add(copperhead); movers.AnimalsThatMoveOnGroundList.Add(gerbil); movers.AnimalsThatMoveOnGroundList.Add(mouse); movers.AnimalsThatMoveOnGroundList.Add(rattlesnake); AnimalsThatSwim swimmers = new AnimalsThatSwim(); swimmers.AnimalsThatSwimList.Add(bettaFish); swimmers.AnimalsThatSwimList.Add(terrapin); }
static void Main(string[] args) { // SkyAnimals Finch finchy = new Finch(); Parakeet perry = new Parakeet(); // LandAnimals Mice mousey = new Mice(); Gerbil gerbilly = new Gerbil(); // WaterAnimals BettaFish betty = new BettaFish(); Terrapin terry = new Terrapin(); // UnderGroundAnimals Ant auntJemima = new Ant(); CopperheadSnake copperFace = new CopperheadSnake(); Earthworm wormy = new Earthworm(); TimberRattlesnake shiver = new TimberRattlesnake(); Flying SkyAnimals = new Flying(); OnGround LandAnimals = new OnGround(); Swimming WaterAnimals = new Swimming(); UnderGround UnderGroundAnimals = new UnderGround(); SkyAnimals.FlyingAnimals.Add(finchy); SkyAnimals.FlyingAnimals.Add(perry); LandAnimals.OnGroundAnimals.Add(mousey); LandAnimals.OnGroundAnimals.Add(gerbilly); WaterAnimals.SwimmingAnimals.Add(betty); WaterAnimals.SwimmingAnimals.Add(terry); UnderGroundAnimals.UnderGroundAnimals.Add(auntJemima); UnderGroundAnimals.UnderGroundAnimals.Add(copperFace); UnderGroundAnimals.UnderGroundAnimals.Add(wormy); UnderGroundAnimals.UnderGroundAnimals.Add(shiver); }
static void Main(string[] args) { // Instantiate ground animals TimberRattler timberRattler1 = new TimberRattler(); Mouse mouse1 = new Mouse(); Copperhead copperhead1 = new Copperhead(); Gerbil gerbil1 = new Gerbil(); // Instantiate digger animals Earthworm earthworm1 = new Earthworm(); Ant ant1 = new Ant(); // Instantiate flyer animals Parakeet parakeet1 = new Parakeet(); Finch finch1 = new Finch(); // Instantiate swimming animals BettaFish bettaFish1 = new BettaFish(); Terrapin terrapin1 = new Terrapin(); GroundBox groundBox1 = new GroundBox(); DiggerBox diggerBox1 = new DiggerBox(); FlyerBox flyerBox1 = new FlyerBox(); SwimmerBox swimmerBox1 = new SwimmerBox(); // Add ground animals to the ground box groundBox1.GroundAnimals.Add(timberRattler1); groundBox1.GroundAnimals.Add(mouse1); groundBox1.GroundAnimals.Add(copperhead1); groundBox1.GroundAnimals.Add(gerbil1); // Add digger animals to the digger box diggerBox1.DiggingAnimals.Add(earthworm1); diggerBox1.DiggingAnimals.Add(ant1); // Add flyer animals to the flyer box flyerBox1.FlyingAnimals.Add(parakeet1); flyerBox1.FlyingAnimals.Add(finch1); // Add swimming animals to the swimmer box swimmerBox1.SwimmingAnimals.Add(bettaFish1); swimmerBox1.SwimmingAnimals.Add(terrapin1); // for each item in each box, execute the common method that belongs to each animal foreach (IGroundable groundAnimal in groundBox1.GroundAnimals) { groundAnimal.MoveOnGround(); } foreach (IDigable diggerAnimal in diggerBox1.DiggingAnimals) { diggerAnimal.Dig(); } foreach (IFlyable flyerAnimal in flyerBox1.FlyingAnimals) { flyerAnimal.Fly(); } foreach (ISwimable swimmingAnimal in swimmerBox1.SwimmingAnimals) { swimmingAnimal.Swim(); } }
static void Main(string[] args) { Ant ant = new Ant() { Dig = true, Name = "Ant", Color = "brown", Food = "dirt" }; BettaFish betta = new BettaFish() { Swim = true, Name = "Betta", Color = "red", Food = "food" }; CopperheadSnake copperSnake = new CopperheadSnake() { Move = true, Name = "Copper", Color = "brown", Food = "mice" }; Earthworm worm = new Earthworm() { Dig = true, Name = "Worm", Color = "brown", Food = "dirt" }; Finch bird = new Finch() { Fly = true, Name = "Bird", Color = "orange", Food = "seeds" }; Gerbil gerbil = new Gerbil() { Move = true, Name = "Gerbil", Color = "brown", Food = "seeds" }; Mice mouse = new Mice() { Move = true, Name = "Mouse", Color = "white", Food = "seeds" }; Parakeet smallBird = new Parakeet() { Fly = true, Name = "Parakeet", Color = "orange", Food = "seeds" }; Rattlesnake rattler = new Rattlesnake() { Move = true, Name = "Rattler", Color = "green", Food = "rats" }; Terrapin turtle = new Terrapin() { Swim = true, Name = "Turts", Color = "green", Food = "fish" }; Container animalContainer = new Container(); animalContainer.Diggers.Add(worm); animalContainer.Diggers.Add(ant); animalContainer.Movers.Add(copperSnake); animalContainer.Movers.Add(gerbil); animalContainer.Movers.Add(mouse); animalContainer.Movers.Add(rattler); animalContainer.Fliers.Add(bird); animalContainer.Fliers.Add(smallBird); animalContainer.Swimmers.Add(betta); animalContainer.Swimmers.Add(turtle); foreach (var animal in animalContainer.Diggers) { Console.WriteLine(animal.ToString()); } foreach (var animal in animalContainer.Movers) { Console.WriteLine(animal.ToString()); } foreach (var animal in animalContainer.Fliers) { Console.WriteLine(animal.ToString()); } foreach (var animal in animalContainer.Swimmers) { Console.WriteLine(animal.ToString()); } }
static void Main(string[] args) { // create one (or more if you like) instances of each type of animal and each container. Then add the animals to their corresponding container. IDigContainer animalsDigging = new IDigContainer(); IFlyContainer animalsThatFly = new IFlyContainer(); ISwimContainer animalsThatSwim = new ISwimContainer(); IMoveContainer animalsThatMove = new IMoveContainer(); Earthworm Ernie = new Earthworm(); Ernie.Name = "Ernie"; Earthworm Ethel = new Earthworm(); Ernie.Name = "Ethel"; animalsDigging.animalsThatDig.Add(Ernie); animalsDigging.animalsThatDig.Add(Ethel); Ant Andy = new Ant(); Andy.Name = "Andy"; Ant Anita = new Ant(); Anita.Name = "Anita"; animalsDigging.animalsThatDig.Add(Andy); animalsDigging.animalsThatDig.Add(Anita); animalsThatMove.Movers.Add(Andy); animalsThatMove.Movers.Add(Anita); CopperHeadSnake Carl = new CopperHeadSnake(); Carl.Name = "Carl"; CopperHeadSnake Carly = new CopperHeadSnake(); Carly.Name = "Carly"; animalsThatMove.Movers.Add(Carl); animalsThatMove.Movers.Add(Carly); Finch Frankie = new Finch(); Frankie.Name = "Frankie"; Finch Fellina = new Finch(); Fellina.Name = "Fellina"; animalsThatFly.Fliers.Add(Frankie); animalsThatFly.Fliers.Add(Fellina); Fish Fanny = new Fish(); Fanny.Name = "Fanny"; Fish Felix = new Fish(); Felix.Name = "Felix"; animalsThatSwim.Swimmers.Add(Fanny); animalsThatSwim.Swimmers.Add(Felix); Gerbil Gretel = new Gerbil(); Gretel.Name = "Gretel"; Gerbil Gary = new Gerbil(); Gary.Name = "Gary"; animalsDigging.animalsThatDig.Add(Gretel); animalsDigging.animalsThatDig.Add(Gary); animalsThatMove.Movers.Add(Gretel); animalsThatMove.Movers.Add(Gary); Mouse Mandy = new Mouse(); Mandy.Name = "Mandy"; Mouse Matt = new Mouse(); Matt.Name = "Matt"; animalsDigging.animalsThatDig.Add(Mandy); animalsDigging.animalsThatDig.Add(Matt); animalsThatMove.Movers.Add(Mandy); animalsThatMove.Movers.Add(Matt); Parakeet Parry = new Parakeet(); Ernie.Name = "Ernie"; Parakeet Patricia = new Parakeet(); Ernie.Name = "Ernie"; animalsThatFly.Fliers.Add(Parry); animalsThatFly.Fliers.Add(Patricia); RattleSnake Randy = new RattleSnake(); RattleSnake Rachel = new RattleSnake(); Randy.Name = "Randy"; animalsThatMove.Movers.Add(Randy); Rachel.Name = "Rachel"; animalsThatMove.Movers.Add(Rachel); Terrapin Tim = new Terrapin(); Terrapin Tina = new Terrapin(); Tim.Name = "Tim"; Tina.Name = "Tina"; animalsThatMove.Movers.Add(Tina); animalsThatMove.Movers.Add(Tim); animalsThatSwim.Swimmers.Add(Tina); animalsThatSwim.Swimmers.Add(Tim); animalsDigging.animalsThatDig.ForEach(animal => { Console.WriteLine($"Animals that Dig: {animal.Name} {animal.GetType().ToString().Split('.')[1]}"); }); animalsThatMove.Movers.ForEach(animal => { Console.WriteLine($"Animals that Move: {animal.Name} {animal.GetType().ToString().Split('.')[1]}"); }); Console.WriteLine("////////////////////////////////////////"); animalsThatSwim.Swimmers.ForEach(animal => { Console.WriteLine($"Animals that Swim: {animal.Name} {animal.GetType().ToString().Split('.')[1]}"); }); Console.WriteLine("////////////////////////////////////////"); animalsThatFly.Fliers.ForEach(animal => { Console.WriteLine($"Animals that Fly: {animal.Name} {animal.GetType().ToString().Split('.')[1]}"); }); Console.WriteLine("////////////////////////////////////////"); }
static void Main(string[] args) { Earthworm LongEarthWorm = new Earthworm(); Ant StrongAnt = new Ant(); List <DigandLiveContainer> DigandLiveContainersList = new List <DigandLiveContainer>() { LongEarthWorm, StrongAnt, }; foreach (DigandLiveContainer animal in DigandLiveContainersList) { Console.WriteLine("I am in the IN-ground container"); } CopperheadSnake BadSnake = new CopperheadSnake(); Gerbil LoveGerbil = new Gerbil(); Mice UglyMice = new Mice(); Terrapin MyTerrapin = new Terrapin(); TimberRattlesnake OhThisSnake = new TimberRattlesnake(); List <MoveOnGroundContainer> MoveOnGroundContainerList = new List <MoveOnGroundContainer>() { BadSnake, LoveGerbil, UglyMice, MyTerrapin, OhThisSnake, }; foreach (MoveOnGroundContainer animal in MoveOnGroundContainerList) { Console.WriteLine("I am running around the ground container"); } BettaFish LonelyFish = new BettaFish(); List <SwimContainer> SwimContainerList = new List <SwimContainer>() { LonelyFish, }; foreach (SwimContainer animal in SwimContainerList) { Console.WriteLine("I am stuck in the swim container"); } Parakeet FlyHigh = new Parakeet(); Finch FlyFinchFly = new Finch(); List <FlyContainer> FlyContainerList = new List <FlyContainer>() { FlyHigh, FlyFinchFly, }; foreach (FlyContainer animal in FlyContainerList) { Console.WriteLine("I am flying around this cage"); } }