Animalsof the same type appear together in the cage window.
Animals of the same type appear together in the cage window.CageWindow.xaml.cs as specified in the diagram below.
DrawAnimal method to refer to the animal parameter instead of the now-nonexistent animal field.DrawAllAnimals method write code to clear the grid's children, loop through all the animals and call the DrawAnimal method for each one.RedrawHandler and window_Loaded event, call the DrawAllAnimals method.GetAnimals method to the Zoo class as shown in the diagram below.In it, make a variable of type List<Animal>. Loop through all the animals; if the current animal's type matches the passed-in type, add it to the list. Then return the list.

showCageButton in the MainWindow, get a collection of animals by calling the zoo's GetAnimals method, passing in the type of the selected animal.Pass that collection into the CageWindow instead of the single animal.
window_Loaded event handler in the MainWindow, add another Dingo to the Zoo with an age of 0.DrawAnimal method, remove the line of code that clears the Children from the cageWindow.Dingo and show the cage window. All dingoes in the zoo should be shown in the cage window.
Animal movement uses the required randomized values.Animal class as specified in the diagram below.
Random, passing in DateTime.Now.Millisecond, as shown in the code belowprivate Random random = new Random(DateTime.Now.Millisecond);Dingo's age from 0 to 1Dingo cage.It appears that there is only one Dingo in the cage when in reality there are two. This is because the Canvas objects are the same size, start in the same place and move the same distance.
Dingo's age back to 0.Next method to set the move distance to the next number between 5 and 15, inclusive.this.MoveDistance = random.Next(5, 16);Next method to set the XPosition to the next number between 1 and the XPositionMax, inclusive.Next method to set the YPosition to the next number between 1 and the YPositionMax, inclusive.If the number is 0, set the XDirection to Left. Otherwise, set it to Right.
If the number is 0, set the YDirection to Up. Otherwise, set it to Down.
Animal constructor.Dingo instance.The values of the YPosition, XPosition, MoveDistance should be "random".
When the breakpoint is hit, the same instance of the Dingo should have different values than before.
Dingo should have different values than the first one.Dingo and click Show cage.The Dingos starting positions, direction, and move speed should now be seemingly random.

Cage objects hold the appropriate animal types.Cage class in the Zoos project as specified in the diagram below.
Animals property simply returns the private list.AnimalType, Height, and Width properties are all auto-properties.Height and Width to the passed in height and width in the constructor.AnimalType property to the animalType parameter in the constructor.Remove methods call the appropriate method on the private list. Pass the animal parameter through.Zoo and Animal classes as specified in the diagram below.
ConvertAnimalTypeToType method, use a switch statement to return the Type that matches the passed-in AnimalTypeType result = null;
switch (animalType)
{
case AnimalType.Chimpanzee:
result = typeof(Chimpanzee);
break;
case AnimalType.Dingo:
result = typeof(Dingo);
break;
case AnimalType.Eagle:
result = typeof(Eagle);
break;
case AnimalType.Hummingbird:
result = typeof(Hummingbird);
break;
case AnimalType.Kangaroo:
result = typeof(Kangaroo);
break;
case AnimalType.Ostrich:
result = typeof(Ostrich);
break;
case AnimalType.Platypus:
result = typeof(Platypus);
break;
case AnimalType.Shark:
result = typeof(Shark);
break;
case AnimalType.Squirrel:
result = typeof(Squirrel);
break;
}
return result;Zoo's constructor, initialize the cages list.Then loop through the values in the AnimalType enum. For each value, add a new cage to the list. Pass in a height of 400 and a width of 800 for all cages. Use the ConvertAnimalTypeToType method to pass in a Type to the Cage constructor.
FindCage method, use a control-break loop to find the cage whose AnimalType property matches the passed-in Type.AddAnimal and RemoveAnimal methods, find the animal's cage and Add or Remove the animal from the cage in addition to adding or removing it from the zoo.CageWindow class as specified in the diagram below.
showCageButton click event, instead of getting a collection of animals to pass to the CageWindow, use the FindCage method to find the appropriate cage and pass that to the CageWindow.window_Loaded event handler in the MainWindow, create two Chimpanzees.Dingo and show their cage window.The dingoes should appear and be moving as they did before adding the cage. Close the cage window.
Chimpanzee and show their cage. The animals should appear and be moving properly.HorizontalDirection and VerticalDirection enumerations to the new project.CagedItems.CagedItems project, create the ICageable interface and have the Animal class implement it as specified in the diagram below.
DisplaySize getter in the Animal class, use a ternary operator to return 0.5 if the animal's age is 0; otherwise, return 1.0.Add a virtual modifer to the property.
Shark -- Baby size: 1. Adult size: 1.5.Platypus -- Baby size: 0.5. Adult size: 1.1.Hummingbird -- Baby size: 0.4. Adult size: 0.6.Ostrich -- Baby size: 0.4. Adult size: 0.8.ResourceKey property in the Animal class, return the Name of the animal's Type plus "Baby" if the animal's age is 0 or "Adult" if the animal is older than 0.This is the same as in the DrawAnimal method in the CageWIndow class.
DrawAnimal method, remove the line of code that assigns the resourceKey and use the ResourceKey property instead.Cage class and CageWindow.xaml.cs as specified in the diagram below.
GetViewBox method with the following // Finished viewBox.
Viewbox finishedViewBox = new Viewbox();
// Gets image ratio.
double imageRatio = canvas.Width / canvas.Height;
// Sets width to a percent of the window size based on it's scale.
double itemWidth = this.cageGrid.ActualWidth * 0.2 * displayScale;
// Sets the height to the ratio of the width.
double itemHeight = itemWidth / imageRatio;
// Sets the width of the viewBox to the size of the canvas.
finishedViewBox.Width = itemWidth;
finishedViewBox.Height = itemHeight;
// Sets the animals location on the screen.
double xPercent = (this.cageGrid.ActualWidth - itemWidth) / maxXPosition;
double yPercent = (this.cageGrid.ActualHeight - itemHeight) / maxYPosition;
int posX = Convert.ToInt32(xPosition * xPercent);
int posY = Convert.ToInt32(yPosition * yPercent);
finishedViewBox.Margin = new Thickness(posX, posY, 0, 0);
// Adds the canvas to the view box.
finishedViewBox.Child = canvas;
// Returns the finished viewBox.
return finishedViewBox;DrawItem method to the top of the GetViewBox method.Place it before the call to create the new ViewBox().
GetViewBox method within the DrawItem method.Guest class as specified in the diagram below.
DisplaySize."Guest" for the ResourceKey.Guest ToString method, if the AdoptedAnimal is not null, attach the Name of the AdoptedAnimal to the string result.adoptAnimalButton to the MainWindow. Give it a click event.AdoptedAnimal.unadoptAnimalButton to the MainWindow. Give it a click event.AdoptedAnimalAdoptedAnimalAdoptedAnimalCageWindow.xaml.cs, rename the DrawAllAnimals method to DrawAllItems and change the Animal type in the foreach loop to ICageable.Guest to add Ethel to the Zoo.Have Ethel adopt an animal. Ethel's representation in the list box should change to reflect the name of her adopted animal.


CageWindow open.Select Ethel and a different animal and click Un-Adopt animal. Ensure you get an error about the animal not being theirs.
Ensure the guest is removed from the CageWindow and that the animal name is removed from their string.
MainWindow and click Remove. Notice that the guest image stays in the window.RemoveGuest method code, include a check whether or not the guest has adopted an animal.RemoveAnimal method, loop through the zoo's list of guests.AdoptedAnimal property to null and remove the guest from the cage.removeAnimalButton_Click event, after the animal is removed, update the guest list box.Remove method in the Cage class.Ensure the program does not crash, but an error message is displayed.
AdotpedAnimal is null.Ensure that the guest and animal selected are removed from the cage window.
Dingo. Do the same for Chimpanzees.Dingo and show its cage.Guest's informationGuestAnimalAnimal's name gets added to the Guest's informationGuest portrait is in the cage as wellGuest and an Animal that isn't their Adopted AnimalAnimal. A message box with an error message should appearNow unadopt the actual Adopted AnimalAnimal removes their Guest from the cageAnimal. The Guest should reappear in the cage.Animal from the zoo. The guest should disappear from the cage.Guest removes the Guest from the cageGuest from the zoo. The guest should disappear from the cage.© 2026 Northcentral Technical College