Currently the TicketBooth and Attendant are being called directly from outside of their classes, which violates encapsulation.
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 2.5 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 errors or warnings.
Currently the TicketBooth and Attendant are being called directly from outside of their classes, which violates encapsulation.
You will make public fields that are used during the Fill Vending Machine sequence private.
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.
TicketBooth field using this story’s design referenceZoo constructor to now reference the private ticketBooth field
Zoo constructor, define the TicketBooth property using the code belowpublic Booth TicketBooth
{
get
{
return this.ticketBooth;
}
}Booth class, modify the visibility of the Employee field using this story’s design referenceBooth constructorpublic Employee Attendant
{
get
{
return this.attendant;
}
}
bettyFillVendingMachineButton_Click on the line that calls the FillVendingMachine methodNew San Diego Zoo. Click Betty, fill vending machineTicketBooth and Attendant properties match those below
TicketBooth property
MainWindow. Ensure that the TicketBooth object was returned
Attendant property
MainWindow. Ensure that the Attendant object was returned
FillVendingMachine method is calledThe Animal class has fields that are still public that can be altered from outside the class.
You will change the visibility of fields and add properties in the Animal class.
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.
Animal class private using this story’s design reference and change how they are referenced in the constructorpublic string Name
{
get
{
return this.name;
}
set
{
this.name = value;
}
}birthDingoButton_Click on the line that calls BirthAnimal and a breakpoint in the Employee class in the DeliverAnimal method on the line that assigns the baby's Name fieldNew Como Zoo button. Click the Birth dingo buttonType property as described in this story’s design referenceWeight property as described in this story’s design referencebaby.Name property is " "
Name property's setter. Ensure the value is "Baby"
Employee class. Ensure that the name of the baby is now "Baby"
Currently we are using methods to retrieve data on the animals in the zoo. While this is acceptable, using properties for this is less cumbersome.
You will refactor the methods that get zoo information into properties.
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.
AnimalCount with a getterGetAnimalCount method and paste it into the AnimalCount propertypublic int AnimalCount
{
get
{
return this.animals.Count;
}
}GetAnimalCount methodAverageAnimalWeight and TotalAnimalWeight by cutting and pasting the method body from CalculateAverageAnimalWeight and CalculateTotalAnimalWeight and then delete the CalculateAverageAnimalWeight and CalculateTotalAnimalWeight methodsYou will need to change the call to CalculateTotalAnimalWeight in the AverageAnimalWeight property to target the TotalAnimalWeight property
MainWindow and Zoo class, replace the calls to GetAnimalCount, GetAverageAnimalWeight and GetTotalAnimalWeight with the new propertiesMainWindow on the lines that call the Como Zoo's AnimalCount and AverageAnimalWeightNew Como Zoo button. Click the Get animal count buttonAnimalCount propertyAnimalCount property and back to the MainWindow. Ensure the value returned is 3Get average animal weightAverageAnimalWeight propertyAverageAnimalWeight property. Ensure that the debugger steps into the TotalAnimalWeight property and the AnimalCount propertyMainWindow. Ensure that the value returned is 28.2MainWindow in the lines that call the San Diego Zoo's AnimalCount, TotalAnimalWeight and AverageAnimalWeightNew San Diego Zoo. Click Get animal countanimalCount variable is assigned the value 2Get average animal weight buttonaverageAnimalWeight variable is assigned the value 1.885The sequence for feeding animals is still accessing public fields that should be private.
You will make remaining public fields private for the feeding animals.
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.
Zoo class, make the fields private and add properties using this story’s design referenceAnimal class, refactor the code so that getting the portion size uses a property instead of a methodGetPortionSize with calls to PortionSizeFood class, make the Weight field private and add a property for itWeight field to target the private weight field instead of the propertyGetMoneyBalance methodmoneyBalanceGetMoneyBalance methodMoneyBalanceFeedAnimal method, use the guest's MoneyBalance property to get the money balancedarlaFeedDingoButton_Click on the line of code that calls FeedAnimalNew Como Zoo. Click the Darla feed dingo button,The sequence for birthing animals is still accessing public fields that should be private.
You will make remaining public fields private for the birthing animals.
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: Make changes to the class structure using this story’s design reference.
Check the result against this instruction: In the Animal class, use a property to determine the pregnancy status of the animal rather than a method.
birthDingoButton_Click on the line that calls BirthAnimalNew Como Zoo button. Click the Birth dingo buttonCurrently if the Zoo keeps birthing animals over and over the temperature of the room could get out of control.
You will define a property with logic inside of it to control the temperature range.
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.
| Value assigned | Expected result |
|---|---|
| 35.0 | Accept lower boundary |
| 95.0 | Accept upper boundary |
| 34.9 | Keep previous temperature |
| 95.1 | Keep previous temperature |
BirthingRoom class, define readonly fields for max and min temperaturesmaxTemperature to 95.0minTemperature to 35.0Temperature property with a getter and setterminTemperature and less than or equal to the maxTemperatureif (value >= this.minTemperature && value <= this.maxTemperature)
{
this.temperature = value;
}BirthAnimal method, change the reference to temperature to reference the Temperature property insteadBirthingRoom class in the BirthAnimal method on the line that increases the TemperatureNew Como Zoo. Click Birth DingoTemperature property's getterBirthAnimal methodTemperature property's setter. Ensure that the Value is 77.5
BirthAnimal method. Ensure that this.temperature is 77.5this.temperature is now 78Currently there are several places in the MainWindow where code can be shortened for readability.
You will refactor parts of the code so that lines are combined.
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.
Booth booth = new Booth(new Employee("Sam", 42), 15.00m);Check the result against this instruction: In the newComoZooButton_Click, in the instantiation of the Booth, replace the attendant variable with an instance of the Employee class using the values on the line above.
Check the result against this instruction: Delete the line of code that assigns the attendant variable.
Check the result against this instruction: In the newSanDiegoZooButton_Click, in the instantiation of the Booth, replace the attendant variable with an instance of the Employee class using the values on the line above.
Check the result against this instruction: Delete the line of code that assigns the attendant variable.
this.comoZoo.Visitor.FeedAnimal(this.comoZoo.FindAnimal("Dingo"), this.comoZoo.AnimalSnackMachine);Check the result against this instruction: In the darlaFeedDingoButton_Click, in the call to FeedAnimal, replace the animal variable with t call to FindAnimal
Check the result against this instruction: In the daveFeedPlatypusButton_Click, in the call to FeedAnimal, replace the animal variable with the call to FindAnimal
newComoZooButton_Click on the line of code that instantiates booth and a breakpoint in the darlaFeedDingoButton_Click on the line that calls FeedAnimalNew Como ZooEmployee constructorMainWindowBooth constructorMainWindow and press F11. Ensure that the booth object has the correct values
FindAnimal methodMainWindowFeedAnimal methodnewSanDiegoZooButton_Click on the line of code that instantiates booth and a breakpoint in the daveFeedPlatypusButton_Click on the line that calls FeedAnimalNew San Diego Zoo button
Currently there is an if/else statement that determines how an animal eats and those can get very difficult to maintain/read.
You will refactor the if/else statement into a switch statement.
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.type)
{
case "Dingo":
this.Bark();
break;
case "Platypus":
this.StashInPouch(food);
break;
default:
// All other animals do nothing special.
break;
}Check the result against this instruction: In the Eat method in the Animal class, replace the entire if/else statement with the switch statement code below.
Animal class in the Eat method on the line of code that begins the switch statementNew Como Zoo. Click Darla feed dingo. Ensure that the type is "Dingo"
"Dingo" case
Bark method"Platypus" case nor the default are hit by the debuggerAnimal class in the Eat method on the line of code that begins the switch statementNew San Diego Zoo. Click Dave, feed platypusStashInPouch method and nothing elseCheck the result against this instruction: Now that everything is private, the suppression message that kept warnings from occurring due to violating encapsulation is no longer necessary.
'Find In Files'FieldsMustBePrivate and delete every occurrenceCheck 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.
Read the booth and attendant through properties Expose controlled animal information Read calculated zoo statistics Feed animals through encapsulated values Read pregnancy and delivery dependencies through properties Keep birthing-room temperature within bounds Simplify window construction and feeding calls Choose special eating behavior with a switchRemove 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.