10-152-311 - Object-Oriented Programming 1

4.3 Restaurant Assignment: Overview

Vladimir has chosen a charity to give any left over breadsticks and soup to at the end of the day. Several Menu Items have been added to the Menu this week as well.

In this assignment, you will create methods and call them by referring to the included UML sequence diagrams.

4.3 Restaurant Assignment: 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.3  Restaurant 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.3 Restaurant Assignment: Object Diagram

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

PNG image of 4.3 Restaurant UML object diagram

4.3 Restaurant Assignment: Code Snippet

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

// Create an instance of the Restaurant class.

// Set field values of Moms.

// Set field values of the dinner menu.

// Set field values of the lunch menu.

// Set field values of the daily special.

// Create a temporary menu item variable.

// Create an instance of the MenuItem class (coffee).

// Set field values of the coffee.

// Add the coffee to the menu's list of items.

// Create an instance of the MenuItem class (lemonade).

// Set field values of the lemonade.

// Add the lemonade to the menu's list of items.

// Create an instance of the MenuItem class (meatloaf).

// Set field values of the meatloaf.

// Add the meatloaf to the menu's list of items.

// Create an instance of the MenuItem class (veggie salad).

// Set field values of the veggie salad.

// Add the veggie salad to the menu's list of items.

// Set field values of the owner.

// Set field values of the breadbasket.

// Set field values of the bread oven.

// Set field values of the charity.

// Set field values of the gas stove.

// Set field values of the soup vat.

// Set field values of the regular.

// Set field values of the regular's ticket.

// Define a temporary menu item variable.

// Create an instance of the MenuItem class (coffee).

// Set field values of the coffee.

// Add the coffee to the ticket.

// Create an instance of the MenuItem class (meatloaf).

// Set field values of the meatloaf.

// Add the meatloaf to the ticket.

// Define a temporary waitress variable.

// Create an instance of the Waitress class (Svanhilde).

// Set field values of Svanhidle.

// Add Svanhilde to the restaurant's list of waitresses.

// Create an instance of the Waitress class (Heidi).

// Set field values of Heidi.

// Add Heidi to the restaurant's list of waitresses.

4.3 Restaurant Assignment: Sequence Diagram 1

prepareDailyFoodButton

PNG image of the 4.3 Restaurant UML sequence diagram #1

4.3 Restaurant Assignment: Sequence Diagram 2

serveLunchToTheRegularButton

PNG image of the 4.3 Restaurant UML sequence diagram #2

4.3 Restaurant Assignment: Final Steps

Method details:

  1. See the comments on the sequence diagrams for the required information to correctly write the code for the various methods.

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.3 Restaurant rubric