10-152-311 - Object-Oriented Programming 1

4.1 Zoo Lab: Overview

In this assignment, create methods and call them from button-click event handlers, passing parameters to them and accepting return values from them, as specified.

This week's object diagram is relatively simple. A couple fields are being deleted, and the two animals that used to be in the birthing room are instead only being added to the zoo's Animals list.

4.1 Zoo Lab: Class Diagram

Implement the changes specified in the following UML class diagram.

Create any button(s) and button click event handler(s) in the WPF window designer (if specified in the class diagram).

PNG image of 4.1  Zoo UML class diagram
  1. When creating classes be sure to:
    1. Ensure the class in the root namespace. This can be done in one of two ways. Either by adding the class in the project, i.e. scenario, or by adding the class to the business classes folder and removing the ".Business_Classes" designation from the namespace.
    2. insert the following line of code immediately above the class definition:
      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate", Justification = "Encapsulation not yet taught.")]
  2. Open the main window (MainWindow.xaml) in designer mode (right-click and click "View Designer" or press Shift-F7 to go to designer mode).

4.1 Zoo Lab: Object Diagram

Instantiate the objects and set their field values as specified in the following UML object diagram.

PNG image of 4.1 Zoo UML object diagram

4.1 Zoo Lab: Code Snippet

Within the newZooButton click event handler use the following code snippet as your guide to writing the code.

// Create an instance of the Zoo class.

// Set field values of Como Zoo.

// Set field values of the animal snack machine.

// Set field values of the dingo food.

// Set field values of the platypus food.

// Set field values of room B168.

// Set field values of the baby animal.

// Set field values of the mother animal.

// Add the baby animal to the zoo's animal list.

// Add the mother animal to the zoo's animal list.

// Define a temporary animal variable.

// Create an instance of the Animal class (Brutus).

// Set field values of Brutus.

// Add Brutus to the zoo's animal list.

// Create an instance of the Animal class (Coco).

// Set field values of Coco.

// Add Coco to the zoo's animal list.

// Create an instance of the Animal class (Paddy).

// Set field values of Paddy.

// Add Paddy to the zoo's animal list.

// Create an instance of the Animal class (Bella).

// Set field values of Bella.

// Add Bella to the zoo's animal list.

// Define a temporary guest variable.

// Create an instance of the Guest class (Sally).

// Set field values of Sally.

// Set field values of Sally's wallet.

// Add Sally to the zoo's guest list.

// Create an instance of the Guest class (Fred).

// Set field values of Fred.

// Set field values of Fred's wallet.

// Add Fred to the zoo's guest list.

// Set field values of the ladies' restroom.

// Set field values of the men's restroom.

// Set field values of the ticket booth.

// Set field values of the ticket booth attendant.

Test, Complete and Submit

  1. Build your program - Eliminate compiler errors and warnings
  2. Debug/Test your program - Set breakpoints, step through code, monitor values
  3. Make your code StyleCop-compliant
  4. Close your Visual Studio solution.
  5. Compress your Visual Studio solution to a zip file.
  6. Submit the zip file via Blackboard.

Grading Rubric

PNG image of the 4.1 Zoo rubric