Overview
Activity
Update the Zoo project to checkpoint 1.6.
User Story
As a developer, I want to complete the Zoo 1.6 checkpoint so the project includes the required programming concepts and behavior.
Acceptance Criteria
- Existing files contain the checkpoint changes shown in this walkthrough.
- The solution builds successfully.
- The application starts and the updated behavior can be exercised.
- Names, casing, namespaces, and member signatures match the checkpoint source.
Task List
- Update 3 existing source files.
- Build the solution and resolve any compiler errors.
- Run the application and verify the new behavior.
Exact Casing Matters
Use the filenames, class names, namespaces, method names, property names, and enum values exactly as shown.
Watch Out For
Do not copy build-output folders such as bin, obj, .vs, or package caches into your working project.
Before You Begin
Start with a clean copy of Zoo 1.5 End. Rename the extracted solution folder and solution file for the current checkpoint before making code changes.
Understand the Changes
new instructional files
existing files changed
project-file updates
Files to create
- None
Files to update
ZooScenario/Business Classes/Employee.csZooScenario/MainWindow.xamlZooScenario/MainWindow.xaml.cs
Create New Files
No new instructional source files are required for this checkpoint.
Update Existing Files
ZooScenario/Business Classes/Employee.cs
Apply the following code changes:
--- 1.5/ZooScenario/Business Classes/Employee.cs
+++ 1.6/ZooScenario/Business Classes/Employee.cs
@@ -26,6 +26,11 @@
public int Number;
/// <summary>
+ /// The animal assigned to this employee.
+ /// </summary>
+ public Animal AssignedAnimal;
+
+ /// <summary>
/// Sells a specific number of tickets.
/// </summary>
/// <param name="ticketCount">The number of tickets sold.</param>
@@ -42,6 +47,10 @@
/// </summary>
public void FeedAnimal()
{
+ if (this.AssignedAnimal != null)
+ {
+ this.AssignedAnimal.Eat(0.5);
+ }
}
}
}
ZooScenario/MainWindow.xaml
Apply the following code changes:
--- 1.5/ZooScenario/MainWindow.xaml
+++ 1.6/ZooScenario/MainWindow.xaml
@@ -24,6 +24,7 @@
<Button x:Name="newComoZooButton" Content="New Como Zoo" Click="newComoZooButton_Click"/>
<Button x:Name="openComoZooButton" Content="Open Como Zoo" Click="openComoZooButton_Click"/>
<Button x:Name="feedComoAnimalButton" Content="Julia, feed dingo" Click="feedComoAnimalButton_Click"/>
+ <Button x:Name="careForComoAnimalButton" Content="Flora, care for shared dingo" Click="careForComoAnimalButton_Click"/>
<Button x:Name="prepareComoBirthingRoomButton" Content="Prepare Como Birthing Room" Click="prepareComoBirthingRoomButton_Click"/>
<Button x:Name="fillComoVendingMachineButton" Content="Fill Como Vending Machine" Click="fillComoVendingMachineButton_Click"/>
<!-- End Como Zoo buttons -->
@@ -43,6 +44,7 @@
<Button x:Name="newSanDiegoZooButton" Content="New San Diego Zoo" Click="newSanDiegoZooButton_Click"/>
<Button x:Name="openSanDiegoZooButton" Content="Open San Diego Zoo" Click="openSanDiegoZooButton_Click"/>
<Button x:Name="feedSanDiegoAnimalButton" Content="Dakota, feed platypus" Click="feedSanDiegoAnimalButton_Click"/>
+ <Button x:Name="careForSanDiegoAnimalButton" Content="Steve, care for shared platypus" Click="careForSanDiegoAnimalButton_Click"/>
<Button x:Name="prepareSanDiegoBirthingRoomButton" Content="Prepare San Diego Birthing Room" Click="prepareSanDiegoBirthingRoomButton_Click"/>
<Button x:Name="fillSanDiegoVendingMachineButton" Content="Fill San Diego Vending Machine" Click="fillSanDiegoVendingMachineButton_Click"/>
<!-- End San Diego Zoo buttons -->
ZooScenario/MainWindow.xaml.cs
Apply the following code changes:
--- 1.5/ZooScenario/MainWindow.xaml.cs
+++ 1.6/ZooScenario/MainWindow.xaml.cs
@@ -89,6 +89,7 @@
this.ComoZoo.BirthArea.Doctor.Name = "Flora";
this.ComoZoo.BirthArea.Doctor.Number = 98;
+ this.ComoZoo.BirthArea.Doctor.AssignedAnimal = this.ComoZoo.FeaturedAnimal;
}
/// <summary>
@@ -148,6 +149,7 @@
// Assign field values of the doctor.
this.SanDiegoZoo.BirthArea.Doctor.Name = "Steve";
this.SanDiegoZoo.BirthArea.Doctor.Number = 24;
+ this.SanDiegoZoo.BirthArea.Doctor.AssignedAnimal = this.SanDiegoZoo.FeaturedAnimal;
}
/// <summary>
@@ -174,6 +176,20 @@
}
/// <summary>
+ /// Cares for the Como Zoo's featured animal through a shared employee reference.
+ /// </summary>
+ /// <param name="sender">The object that initiated the event.</param>
+ /// <param name="e">The event arguments for the event.</param>
+ private void careForComoAnimalButton_Click(object sender, RoutedEventArgs e)
+ {
+ this.ComoZoo.BirthArea.Doctor.FeedAnimal();
+ this.informationTextBox.Text = this.ComoZoo.BirthArea.Doctor.Name + " cared for "
+ + this.ComoZoo.FeaturedAnimal.Name + ". Featured animal weight: "
+ + this.ComoZoo.FeaturedAnimal.Weight + ". Birthing room mother weight: "
+ + this.ComoZoo.BirthArea.Mother.Weight + ".";
+ }
+
+ /// <summary>
/// Prepares the Como Zoo's birthing room.
/// </summary>
/// <param name="sender">The object that initiated the event.</param>
@@ -210,7 +226,7 @@
/// Feeds the San Diego Zoo's featured animal.
/// </summary>
/// <param name="sender">The object that initiated the event.</param>
- /// <param name="e">The event arguments for the event.</param>>
+ /// <param name="e">The event arguments for the event.</param>
private void feedSanDiegoAnimalButton_Click(object sender, RoutedEventArgs e)
{
double foodWeight = this.SanDiegoZoo.FeedFeaturedAnimal();
@@ -219,6 +235,20 @@
}
/// <summary>
+ /// Cares for the San Diego Zoo's featured animal through a shared employee reference.
+ /// </summary>
+ /// <param name="sender">The object that initiated the event.</param>
+ /// <param name="e">The event arguments for the event.</param>
+ private void careForSanDiegoAnimalButton_Click(object sender, RoutedEventArgs e)
+ {
+ this.SanDiegoZoo.BirthArea.Doctor.FeedAnimal();
+ this.informationTextBox.Text = this.SanDiegoZoo.BirthArea.Doctor.Name + " cared for "
+ + this.SanDiegoZoo.FeaturedAnimal.Name + ". Featured animal weight: "
+ + this.SanDiegoZoo.FeaturedAnimal.Weight + ". Birthing room mother weight: "
+ + this.SanDiegoZoo.BirthArea.Mother.Weight + ".";
+ }
+
+ /// <summary>
/// Prepares the San Diego Zoo's birthing room.
/// </summary>
/// <param name="sender">The object that initiated the event.</param>
Check Your Work
- Save all files.
- Build the solution.
- Resolve compiler errors before continuing.
- Run the application.
- Exercise the behavior associated with Zoo 1.6.
- Compare your filenames, namespaces, signatures, and key values with the code shown above.
Summary
You completed Zoo 1.6 by creating the required files, modifying only files with meaningful source changes, and verifying the application.