Overview
Methods and Object Collaboration
In this activity, you will continue from Zoo 1.2 and add the fields, methods, controls, and event handlers that make the zoo objects work together.
User Story: Put the Zoo Objects to Work
The zoo manager wants both zoo records to support a current visitor and four daily actions: opening the zoo, feeding the featured animal, preparing the birthing room, and filling the animal snack machine.
Acceptance Criteria
- Add complete
GuestandWalletclasses. - Add the exact Zoo 1.3 fields and methods to the existing business classes.
- Create Julia and Dakota with the checkpoint’s exact wallet balances.
- Add eight action buttons and eight matching event handlers.
- Run the application and verify the exact object-state changes.
Task List
- Prepare Your Zoo 1.2 Checkpoint
- Create the Guest Class
- Create the Wallet Class
- Add Core Business-Class Behavior
- Add Vending Machine and Zoo Behavior
- Create and Initialize the Visitors
- Add the Zoo Action Buttons
- Add the Eight Event Handlers
- Run and Verify the New Behavior
- Finish and Submit
- Review the Checkpoint Summary
Use the class names, method names, event-handler names, messages, and numeric values exactly as shown. Small differences can prevent XAML from connecting to the code-behind or can produce the wrong checkpoint state.
Existing-file examples show only the additions. New-file examples show the complete file. Each code display restarts its section-relative numbering at 01; those display numbers are not editor line numbers.
Prepare Your Zoo 1.2 Checkpoint
The Goal
Continue from your completed
Zoo 1.2 Endproject so this activity adds only the 1.3 changes.Create the Guest Class
The Goal
Add a new business class that represents the visitor currently entering a zoo.
Your Task
In the ZooScenario/Business Classes folder, add
Guest.cs. This is a new file, so enter the complete file shown.ZooScenario/Business Classes/Guest.csusing System; using System.Collections.Generic; using System.Text; namespace ZooScenario { /// <summary> /// The class which is used to represent a guest. /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Encapsulation not yet taught.")] public class Guest { /// <summary> /// The age of the guest. /// </summary> public int Age; /// <summary> /// The name of the guest. /// </summary> public string Name; /// <summary> /// The guest's wallet. /// </summary> public Wallet Wallet; /// <summary> /// Buys a ticket. /// </summary> public void BuyTicket() { this.Wallet.RemoveTicketPrice(); } /// <summary> /// Visits the zoo. /// </summary> public void VisitZoo() { this.BuyTicket(); } } }Create the Wallet Class
The Goal
Give each guest a separate object that stores the guest’s available money.
Your Task
Add
Wallet.csto the same business-class folder. Enter the complete new file.ZooScenario/Business Classes/Wallet.csusing System; using System.Collections.Generic; using System.Text; namespace ZooScenario { /// <summary> /// The class which is used to represent a wallet. /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Encapsulation not yet taught.")] public class Wallet { /// <summary> /// The amount of money currently contained within the wallet. /// </summary> public decimal MoneyBalance; /// <summary> /// Adds money to the wallet. /// </summary> public void AddMoney() { this.MoneyBalance = this.MoneyBalance + 5.00m; } /// <summary> /// Removes the ticket price from the wallet. /// </summary> public void RemoveTicketPrice() { this.MoneyBalance = this.MoneyBalance - 15.00m; } } }Money ValuesThe
msuffix makes values such as5.00mdecimal values. Keep the exact amounts shown in the checkpoint.Add Core Business-Class Behavior
The Goal
Add behavior to the existing animal, room, booth, and employee classes.
Your Task
Place each snippet inside the named class, after the existing fields and before the class closing brace. The snippets show only the additions.
ZooScenario/Business Classes/Animal.cs/// <summary> /// Feeds the animal. /// </summary> public void Eat() { this.Weight = this.Weight + 0.5; this.HappinessLevel = this.HappinessLevel + 2; } /// <summary> /// Makes the animal move. /// </summary> public void Move() { this.HappinessLevel = this.HappinessLevel + 1; } /// <summary> /// Makes the animal wake up and move. /// </summary> public void WakeUp() { this.Move(); }ZooScenario/Business Classes/BirthingRoom.cs/// <summary> /// Warms the birthing room. /// </summary> public void WarmRoom() { this.Temperature = this.Temperature + 0.5; } /// <summary> /// Helps the mother animal rest. /// </summary> public void WakeMotherUp() { this.Mother.WakeUp(); this.WarmRoom(); }ZooScenario/Business Classes/Booth.cs/// The amount of money in the booth. /// </summary> public decimal MoneyBalance; /// <summary> /// <summary> /// Sells a ticket from the booth. /// </summary> public void SellTicket() { this.MoneyBalance = this.MoneyBalance + this.TicketPrice; this.Attendant.SellTicket(); }ZooScenario/Business Classes/Employee.cs/// The number of tickets the employee has sold. /// </summary> public int TicketsSold; /// <summary> /// <summary> /// Sells a ticket. /// </summary> public void SellTicket() { this.TicketsSold = this.TicketsSold + 1; } /// <summary> /// Feeds the animal assigned to this employee. /// </summary> public void FeedAnimal() { }Add Vending Machine and Zoo Behavior
The Goal
Finish the checkpoint’s method chain so the zoo can coordinate visitor, animal, room, and vending-machine work.
Your Task
Add the following members inside their existing classes. Keep the exact method calls and values.
ZooScenario/Business Classes/VendingMachine.cs/// <summary> /// Adds a bag of food to the vending machine. /// </summary> public void AddFoodBag() { this.FoodStock = this.FoodStock + 65.0; } /// <summary> /// Fills the vending machine. /// </summary> public void FillVendingMachine() { this.AddFoodBag(); this.AddFoodBag(); } /// <summary> /// Adds money to the vending machine. /// </summary> public void AddMoney() { this.MoneyBalance = this.MoneyBalance + 5.00m; }ZooScenario/Business Classes/Zoo.cs/// <summary> /// The zoo's current visitor. /// </summary> public Guest Visitor; /// <summary> /// Opens the zoo for a visitor. /// </summary> public void OpenForVisitor() { this.SellTicket(); this.FeaturedAnimal.WakeUp(); } /// <summary> /// Sells a ticket to the visitor. /// </summary> public void SellTicket() { this.Visitor.BuyTicket(); this.TicketBooth.SellTicket(); } /// <summary> /// Feeds the featured animal. /// </summary> public void FeedFeaturedAnimal() { this.FeaturedAnimal.Eat(); this.AnimalSnackMachine.AddMoney(); } /// <summary> /// Prepares the birthing room. /// </summary> public void PrepareBirthingRoom() { this.BirthArea.WakeMotherUp(); } /// <summary> /// Fills the animal snack machine. /// </summary> public void FillAnimalSnackMachine() { this.AnimalSnackMachine.FillVendingMachine(); }Create and Initialize the Visitors
The Goal
Connect one visitor and wallet to each zoo and initialize the new money values.
Your Task
In ZooScenario/MainWindow.xaml.cs, add these statements inside the matching
newComoZooButton_ClickandnewSanDiegoZooButton_Clickevent handlers. Place object creation before field assignments.Current object state after this task. ZooScenario/MainWindow.xaml.csthis.ComoZoo.Visitor = new Guest(); this.ComoZoo.Visitor.Wallet = new Wallet(); this.ComoZoo.Visitor.Age = 12; this.ComoZoo.Visitor.Name = "Julia"; this.ComoZoo.Visitor.Wallet.MoneyBalance = 25.00m; this.ComoZoo.TicketBooth.MoneyBalance = 0.00m; this.SanDiegoZoo.Visitor = new Guest(); this.SanDiegoZoo.Visitor.Wallet = new Wallet(); this.SanDiegoZoo.Visitor.Age = 10; this.SanDiegoZoo.Visitor.Name = "Dakota"; this.SanDiegoZoo.Visitor.Wallet.MoneyBalance = 35.00m; this.SanDiegoZoo.TicketBooth.MoneyBalance = 0.00m;Add the Zoo Action Buttons
The Goal
Add four action buttons for each zoo while preserving the two existing New Zoo buttons.
Your Task
In ZooScenario/MainWindow.xaml, add the Como buttons inside the Como button panel and the San Diego buttons inside the San Diego button panel. The snippet contains only the eight new buttons.
ZooScenario/MainWindow.xaml<Button x:Name="openComoZooButton" Content="Open Como Zoo" Click="openComoZooButton_Click"/> <Button x:Name="feedComoAnimalButton" Content="Feed Como Animal" Click="feedComoAnimalButton_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"/> <Button x:Name="openSanDiegoZooButton" Content="Open San Diego Zoo" Click="openSanDiegoZooButton_Click"/> <Button x:Name="feedSanDiegoAnimalButton" Content="Feed San Diego Animal" Click="feedSanDiegoAnimalButton_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"/>
Replace this placeholder with a light and dark screenshot of the running Zoo 1.3 application showing all action buttons. Add the Eight Event Handlers
The Goal
Connect each new button to the matching
Zoomethod and display the checkpoint’s exact status message.Your Task
In ZooScenario/MainWindow.xaml.cs, add these methods inside the
MainWindowclass, after the existing New Zoo handlers and before the class closing brace.ZooScenario/MainWindow.xaml.cs/// <summary> /// Opens the Como Zoo for a visitor. /// </summary> /// <param name="sender">The object that initiated the event.</param> /// <param name="e">The event arguments for the event.</param> private void openComoZooButton_Click(object sender, RoutedEventArgs e) { this.ComoZoo.OpenForVisitor(); this.informationTextBox.Text = "The Como Zoo is open for " + this.ComoZoo.Visitor.Name + "."; } /// <summary> /// Feeds the Como 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> private void feedComoAnimalButton_Click(object sender, RoutedEventArgs e) { this.ComoZoo.FeedFeaturedAnimal(); this.informationTextBox.Text = this.ComoZoo.FeaturedAnimal.Name + " has been fed."; } /// <summary> /// Prepares the Como Zoo's birthing room. /// </summary> /// <param name="sender">The object that initiated the event.</param> /// <param name="e">The event arguments for the event.</param> private void prepareComoBirthingRoomButton_Click(object sender, RoutedEventArgs e) { this.ComoZoo.PrepareBirthingRoom(); this.informationTextBox.Text = "The Como Zoo birthing room is ready."; } /// <summary> /// Fills the Como Zoo's animal snack machine. /// </summary> /// <param name="sender">The object that initiated the event.</param> /// <param name="e">The event arguments for the event.</param> private void fillComoVendingMachineButton_Click(object sender, RoutedEventArgs e) { this.ComoZoo.FillAnimalSnackMachine(); this.informationTextBox.Text = "The Como Zoo animal snack machine has been filled."; } /// <summary> /// Opens the San Diego Zoo for a visitor. /// </summary> /// <param name="sender">The object that initiated the event.</param> /// <param name="e">The event arguments for the event.</param> private void openSanDiegoZooButton_Click(object sender, RoutedEventArgs e) { this.SanDiegoZoo.OpenForVisitor(); this.informationTextBox.Text = "The San Diego Zoo is open for " + this.SanDiegoZoo.Visitor.Name + "."; } /// <summary> /// 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> private void feedSanDiegoAnimalButton_Click(object sender, RoutedEventArgs e) { this.SanDiegoZoo.FeedFeaturedAnimal(); this.informationTextBox.Text = this.SanDiegoZoo.FeaturedAnimal.Name + " has been fed."; } /// <summary> /// Prepares the San Diego Zoo's birthing room. /// </summary> /// <param name="sender">The object that initiated the event.</param> /// <param name="e">The event arguments for the event.</param> private void prepareSanDiegoBirthingRoomButton_Click(object sender, RoutedEventArgs e) { this.SanDiegoZoo.PrepareBirthingRoom(); this.informationTextBox.Text = "The San Diego Zoo birthing room is ready."; } /// <summary> /// Fills the San Diego Zoo's animal snack machine. /// </summary> /// <param name="sender">The object that initiated the event.</param> /// <param name="e">The event arguments for the event.</param> private void fillSanDiegoVendingMachineButton_Click(object sender, RoutedEventArgs e) { this.SanDiegoZoo.FillAnimalSnackMachine(); this.informationTextBox.Text = "The San Diego Zoo animal snack machine has been filled."; }Run and Verify the New Behavior
The Goal
Use the Como Zoo controls in order and inspect the exact state changes produced by the method calls.
Current object state after this task. 
Replace this placeholder with a debugger screenshot showing Julia wallet 10.00, booth balance 15.00, TicketsSold 1, and Dolly HappinessLevel 1. Current object state after this task. Finish and Submit
Verify Your Work

Replace this placeholder with the completed Zoo 1.3 application running after the new controls have been tested. Go to topSubmit Your Work
Stop debugging, save your work, and submit according to your instructor’s directions.
Feedback System
Checkpoint Summary
Your Zoo 1.3 project now includes guests and wallets, coordinated business methods, new user-interface controls, and event handlers that update and display object state.
- Julia begins with
25.00m; Dakota begins with35.00m. - Opening a zoo sells one ticket and wakes the featured animal.
- Feeding, preparing the birthing room, and filling the vending machine update the exact checkpoint values.