With as many animals and possible animals that the zoo has/can have, the Animal class will become unwieldy.
This page is currently being built. Please check back soon.

Work through the user stories in order. Each story states the goal and acceptance criteria; its nested tasks retain the detailed implementation and verification steps.
Check the result against this instruction: Copy your 3.1 ending code, renaming both the folder and the Visual Studio solution file
Check the result against this instruction: Build your solution and ensure it compiles without warnings or errors.
With as many animals and possible animals that the zoo has/can have, the Animal class will become unwieldy.
You will define a class that represents a Dingo and have it inherit from the Animal class so that it has access to the Animal class, but also can have its own functionality.
This focused design shows the members or flow relevant to this feature. Keep unchanged members from your preceding checkpoint; follow the tasks below for the order of intermediate edits.
public class Dingo : Animal
{
public Dingo(string gender, string name, int age, double weight)
{
}
}public Dingo(string gender, string name, int age, double weight)
: : base("Dingo", gender, name, age, weight)
{
}Passing in "Dingo" here is necessary because the Animal constructor requires a string for the type of Animal.
// Create Dolly
Animal animal = new Dingo("Female", "Dolly", 4, 35.3);
animal.MakePregnant();
this.comoZoo.AddAnimal(animal);
// Create Dixie.
animal = new Dingo("Female", "Dixie", 3, 33.8);
animal.MakePregnant();
this.comoZoo.AddAnimal(animal);Check the result against this instruction: In the MainWindow, modify the lines of code that instantiate Dolly and Dixie by replacing Animal with Dingo and deleting the type argument.
The Autos window does not handle inheritance constructors well so use the Locals window or hover over values to check them.


The zoo still has platypodes (that's right...that's the plural for platypus) and hummingbirds that need their own functionality.
You will define classes and instantiate animals using inherited classes.
This focused design shows the members or flow relevant to this feature. Keep unchanged members from your preceding checkpoint; follow the tasks below for the order of intermediate edits.
Check the result against this instruction: Add and define classes for Platypus and Hummingbird and have them inherit from the Animal class.
Check the result against this instruction: Build your solution and ensure it compiles without errors or warnings.
Check the result against this instruction: In the Platypus and Hummingbird constructors, call the base constructor and pass in the type string and the proper arguments.
Check the result against this instruction: In the MainWindow, refactor the instantiation of the animals to call their respective classes and remove the type argument.


Currently we are relying heavily on using the "type" of animal as a string to perform many of the procedures in the code, but doing that is prone to error.
Now that we have animals being instantiated through their own classes, we can use those classes as a "type" instead of strings.
This focused design shows the members or flow relevant to this feature. Keep unchanged members from your preceding checkpoint; follow the tasks below for the order of intermediate edits.
switch (this.GetType().Name)if (this.GetType().Name != "Platypus")Check the result against this instruction: In the Dingo, Hummingbird, and Platypus classes, remove the string argument from base that assigns the type of Animal it is.
if (a.GetType() == type)this.comoZoo.Visitor.FeedAnimal(this.comoZoo.FindAnimal(typeof(Dingo)), this.comoZoo.AnimalSnackMachine);this.sanDiegoZoo.BirthAnimal(this.sanDiegoZoo.FindPregnantAnimal(typeof(Platypus)));Check the result against this instruction: In the MainWindow, replace the strings that are passed in to the FindAnimal and FindPregnantAnimal methods to the typeof whatever animal type needs to be found.
Check the result against this instruction: Build your solution and ensure that there are no errors or warnings.



Now that we don't have a type field anymore, the baby being instantiated will be a generic Animal type and if it's born will look like an abomination.
You will use a switch statement to determine the type of the animal giving birth and then instantiate a baby animal based on that.
This focused design shows the members or flow relevant to this feature. Keep unchanged members from your preceding checkpoint; follow the tasks below for the order of intermediate edits.
switch (this.GetType().Name)Check the result against this instruction: In the MakePregnant method in the Animal class, inside of the existing if statement, replace the line currently instantiating the baby with a switch statement that uses GetType to get the Name of the type.
case "Dingo":
this.baby = new Dingo("Male", string.Empty, 0, this.Weight * this.babyWeightPercentage);
break;Check the result against this instruction: In the switch statement, if the Name is Dingo, instantiate a type of Dingo. If it is a Platypus, instanti Platypus. If it is a Hummingbird, instantiate a Hummingbird.
We defined the way a Dingo eats but don't have any definition for how a Platypus eats.
You will define how a Platypus eats using inheritance.
This focused design shows the members or flow relevant to this feature. Keep unchanged members from your preceding checkpoint; follow the tasks below for the order of intermediate edits.
Check the result against this instruction: Remove the StashInPouch method from the Animal class and put it inside the Platypus class and add an Eat method that is an override.
Check the result against this instruction: Inside the Eat method in the Platypus class, call the StashInPouch method and pass in the food parameter and then call the Eat method on base and pass in the food parameter.
Currently when all animals eat their weight gain percentage goes up the same amount, but different type of animals gain weight at different rates.
You will define additional classes that inherit from the Animal class so that Mammals and Birds gain weight differently.
This focused design shows the members or flow relevant to this feature. Keep unchanged members from your preceding checkpoint; follow the tasks below for the order of intermediate edits.
| Category | Percentage | How to verify |
|---|---|---|
| Mammal | 0.8 | Food weight multiplied by 0.8 |
| Bird | 0.64 | Food weight multiplied by 0.64 |
Dingo : MammalCheck the result against this instruction: Change the Dingo and Platypus classes to inherit from Mammal and the Hummingbird class to inherit from Bird.
public override double EatWeightGainPercentage
{
get
{
return this.eatWeightGainPercentage;
}
}EatWeightGainPercentage property that returns 0.0
EatWeightGainPercentage property.
This will be done purely for organizational purposes. Moving cs files to other folders in the project will not effect anything.


Check the result against this instruction: Ensure that all code is StyleCop compliant.
Check the result against this instruction: Zip the solution and submit to the Feedback System
Check the result against this instruction: Submit the Feedback System url to the correct assignment in Canvas.
Return to each user story and confirm that you can demonstrate its acceptance criteria. Use the task checkboxes to track completion; a checked box is not a substitute for testing or inspecting the required evidence.
Represent dingoes with a derived class Represent platypuses and hummingbirds with derived classes Find animals using runtime types Construct a newborn of the correct species Let a dingo extend the shared eating behavior Let a platypus stash food before eating Use mammal and bird weight-gain rulesRemove temporary lines used only to demonstrate compile-time errors. Build without errors or warnings, check StyleCop compliance, and rerun the required scenario paths.
Use the submission or attendance instructions in this page. For a Feedback System submission, upload the requested ZIP, review and resolve the feedback, and submit the resulting URL to the matching Canvas activity. For a Canvas quiz, enter only the requested answers; for an oral final, complete the scheduling and attendance steps.