4.1B Zoo Assignment

4.1B Zoo Assignment
Create method stubs
Acceptance Criteria
Acceptance criteria
  • The admission button, method stubs, and properties provide the structure required for a booth visit.
1.Create method stubs
Problem
Solution
A Create a button in MainWindow.xaml named admitGuestButton. Set the Content property of the button to "Admit Guest".
4.1.8 How to Create a Button in XAML
Wireframe: Admit Guest Button. Reference figure for create method stubs.
Wireframe: Admit Guest Button
B Create and/or modify the methods and properties as specified in the class diagram below.
Admit Guest Methods. Reference figure for create method stubs.
Admit Guest Methods
C Modify the creation of the water bottles in the Booth constructor to use the WaterBottlePrice property instead of a hard-coded value.
D Create new tickets for Darla and Greg in the CreateComoZoo method in the MainWindow.xaml.cs by storing them in local variables.
E Check Your Work: Build the solution and ensure that there are no errors or compiler warnings.
Write a sequence of methods to sell a ticket to a guest
Acceptance Criteria
Acceptance criteria
  • A guest's ticket purchase follows the required method sequence and redeems the ticket.
2.Write a sequence of methods to sell a ticket to a guest
Problem
Solution
A In the admit guest button's click event, instantiate a new guest who is 42, named Ethel, has $30, and a salmon-colored wallet.
B Add method calls and returns to methods as specified in the sequence diagram below.

The sequence starts with the click event for the admitGuestButton.

Sequence Diagram: AdmitGuest. Reference figure for write a sequence of methods to sell a ticket to a guest.
Sequence Diagram: AdmitGuest
C Within the booth's SellTicket method, only find a ticket if the guest has provided sufficient funds.
D Add the payment to the booth's money balance if a ticket was found.
E The employee's FindTicket method should first check to see if the number of items in the list is greater than zero.

If so, store the first item in a variable, remove the item from the list, and then return the item.

4.1.9 How to Remove an Item from a List
F In the Redeem method. Set the ticket's isRedeemed field to true.
G Check Your Work
1 Set a breakpoint in the click event for the admitGuestButton.
2 Run the WPF application.
3 Click the Admit guest button.

Step through the code to ensure each method is called correctly. Check for the following results:

Subtasks
  • A. A ticket should be returned from the Employee's FindTicket method all the way back to the MainWindow, and the guest should be admitted to the zoo.
  • B. The found ticket should be removed from the booth's list of tickets (check the serial numbers).
4 Click the Admit guest button four more times.

Ensure that a null reference occurs when trying to admit the sixth guest.

H Within the CreateComoZoo method, use the comoZoo's SellTicket method to pass in legitimate tickets to the zoo for Darla and Greg in the call to the comoZoo's AddGuest method.

It will be necessary to delete the local variable tickets to use the ticket objects returned from the call to the SellTicket method.

I Check Your Work
1 Set a breakpoint in the CreateComoZoo method.
2 Run the WPF application.
3 Ensure that a null reference exception is generated in the AddGuest method.
J When creating Darla, set her wallet's money balance to 25.25 instead of 5.25.
K Check Your Work
1 Set a breakpoint in the click event for the admitGuestButton.
2 Run the WPF application.
3 Click the Admit guest button four times.

Ensure that a null reference exception is generated in the AddGuest method due to there being no tickets remaining.

Add method details
Acceptance Criteria
Acceptance criteria
  • Ticket purchases check available funds, update the booth balance, and require a ticket for admission.
3.Add method details
Problem
Solution
A The booth's SellTicket method should check to see if the given payment is enough to purchase a ticket.

If so, find a ticket.

B The booth's SellTicket method should also check to see if the found ticket exists.

If it does, add the payment to the booth's money balance.

C Check Your Work
1 Set a breakpoint in the button click for the admitGuestButton.
2 Run the WPF application.
3 Click the Admit guest buttons.

Step through the code to ensure each method is called correctly. Check for these results:

Subtasks
  • A. A ticket is returned from the employee's FindTicket method and back through to the MainWindow.
  • B. The ticketBooth gains $15 after the sale of a ticket.
  • C. A guest loses $15 after a visit to the ticketBooth and the purchase of a ticket.
  • D. The guest is admitted to the zoo after being sold a ticket to the zoo.
4 In MainWindow.xaml.cs, change the ticket price passed into the Zoo's constructor to 17m.
  • Click the Admit guest button.
  • Ensure that $17 was removed from the guest's wallet and added to the booth's money balance.
  • The ticket price should only have been changed in one place.
  • After checking this, change the ticket price back to 15m.
Get more booth items during a visit to the ticket booth
Acceptance Criteria
Acceptance criteria
  • A booth visit can also supply a water bottle, map, and coupon book.
4.Get more booth items during a visit to the ticket booth
Problem
Solution
A Add method calls to the VisitTicketBooth method as specified in the sequence diagram below.
Sequence Diagram: VisitTicketBooth. Reference figure for get more booth items during a visit to the ticket booth.
Sequence Diagram: VisitTicketBooth
B The FindWaterBottle, FindMap, and FindCouponBook methods should be similar to the FindTicket method.
C The SellWaterBottle method is similar to the SellTicket method, including the check to see if the payment is enough.

The GiveFreeMap and GiveFreeCouponBook are also similar but do not check for payment because no payment is required.

D Do not do anything with the resulting water bottle, map and coupon book. Only return the ticket.
E Check Your Work
1 Set a breakpoint in the VisitTicketBooth method.
2 Run the WPF application.
3 Click the Admit guest buttons.

Step through the code to ensure each method is called correctly. Check for these results:

Subtasks
  • A. Selling a water bottle should result in a gain of $3 to the booth's money balance and a loss of $3 to the guest's money balance. The sold water bottle should be removed from the list.
  • B. Giving a map should remove the map from the list.
  • C. Giving a coupon book should remove the coupon book from the list.
  • D. Click the Admit guest button at least four times. Ensure that a null reference exception is thrown because there aren't any water bottles or other item types left in their respective lists.
Demonstrate your work
5.Record a video of your application showing
A That your Admit Guest button
1 admits a Guest with values described in Step 2A
2 follows the order of the Sequence Diagram in Step 4A
3 causes a Null Reference Exception if clicked 4 times
Prepare and submit your work
6.Submission Steps
A Ensure that your application has no compiler errors or warnings
B Ensure that your code is StyleCop compliant
C Remove all bin and obj folders from your solution
D Zip your solution
E Submit your zipped solution to the Feedback System
F Submit your Feedback System results link to Canvas
G Submit your video recording to your f-channel
Source credit

© 2026 Northcentral Technical College