Object-Oriented Programming 1: 3.2 Restaurant Assignment

  1. Use a parameter to add breadsticks to the basket
  2. The cook needs to know how many breadsticks were baked in order to add them to the basket. In this task, you will add a parameter to the AddBreadsticks method. You will check your work by setting a breakpoint, stepping through the method call, and ensuring the parameter is set to the correct value.

    1. Add the numberToAdd parameter to the basket's AddBreadsticks method, as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding parameter to add breadsticks
    3. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
    4. Pass 10 as the parameter when calling the AddBreadSticks method. The new method call is shown in the sequence diagram below.
    5. 3.2 Restaurant - sequence diagram for calling add breadsticks with parameter
    6. Ensure that all code is StyleCop compliant.
    7. Check your work:
      1. Set a breakpoint in the MakeBreadsticks method on the line that calls the AddBreadsticks method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Prepare daily food button.
      4. Press F11 to step into the AddBreadsticks method. Ensure that the value of the numberToAdd parameter is 10.
  3. Use a parameter to add soup to the vat
  4. The cook needs to know how much soup was made in order to add it to the vat. In this task, you will add a parameter to the vat's FillSoup method. You will check your work by setting a breakpoint, stepping through the methods, and ensuring that the parameter has the correct value.

    1. Add the amountToAdd parameter to the vat's FillSoup method, as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding parameter to the fill soup method
    3. Pass 7.5 as the parameter when calling the FillSoup method. The new method call is shown in the sequence diagram below.
    4. 3.2 Restaurant - sequence diagram for calling fill soup method with parameter
    5. Ensure that all code is StyleCop compliant.
    6. Check your work:
      1. Set a breakpoint in the MakeSoup method on the line that calls the FillSoup method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Prepare daily food button.
      4. Press F11 to step into the FillSoup method. Inspect the parameter and ensure that its value is 7.5.
  5. Add a booth to the restaurant
  6. The restaurant owner would like to have booths for the patrons. In this task, you will define a class to represent booths and add a booth field to the restaurant. You will check your work by setting a breakpoint, stepping through the code, and ensuring the booth object is instantiated correctly.

    1. Create a new class called Booth in the Business Classes folder and define it as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for booth class
    3. Add the Booth field to the Restaurant class as shown in the class diagram above.
    4. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
    5. Instantiate the Booth field and set its field values.
      1. In the newRestaurantButton_Click, create an instance of the Booth class and assign it to the restaurant's Booth field. Put this line of code immediately above the line that sets the restaurant's capacity.
      2. In the newRestaurantButton_Click underneath the code that sets the restaurant's fields, write the following code comment:
      3. // Set field values of the booth.
      4. Underneath the code comment, set the field values of the booth as specified in the object diagram below.
      5. 3.2 Restaurant - object diagram for setting booth fields

        Tip: The booth's boolean IsOccupied and IsSet fields will automatically be set to false.

    6. Ensure that all code is StyleCop compliant.
    7. Check your work:
      1. Set a breakpoint in the newRestaurantButton_Click on the line that instantiates the Booth field.
      2. Start the application.
      3. Click the New restaurant button.
      4. Press F10 to step over the line of code that instantiates the Booth field. Ensure that the field is instantiated correctly.
      5. Press F10 to step over the code that sets the booth's fields. Ensure that the value of each field is set correctly.
  7. Use a parameter to bus the table
  8. The server needs access to the booth in order to bus the table. In this task, you will add a parameter to the server's BusTable method. You will check your work by setting a breakpoint, stepping through the method call, and ensuring that the parameter is the correct object.

    1. Add the booth parameter to the server's BusTable method as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding parameter to bus table method
    3. Pass in the restaurant's Booth field when calling the server's BusTable method. The updated method call is shown in the sequence diagram below.
    4. 3.2 Restaurant - sequence diagram for calling bus table method with parameter
    5. Check your work:
      1. Set a breakpoint in the restaurant's SetUpTable method on the line that calls the BusTable method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, set up table button.
      4. Press F11 to step into the BusTable method. Ensure that the booth parameter is the same object as the restaurant's Booth field.
    6. In the server's BusTable method, call the ClearTable method on the booth parameter, as shown in the sequence diagram below.
    7. 3.2 Restaurant - sequence diagram for calling the clear table method
    8. Ensure that all code is StyleCop compliant.
    9. Check your work:
      1. Set a breakpoint in the server's BusTable method on the line that calls the ClearTable method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, set up table button.
      4. Press F11 to step into the ClearTable method. Ensure that you stepped into the restaurant's booth object.
  9. Use a parameter to set the table and fill condiments
  10. The server needs access to the booth in order to set the table and fill condiments. In this task, you will add parameters to two of the server's methods. You will check your work by setting a breakpoint, stepping into the methods, and ensuring that the parameters contain the correct object.

    1. Add booth access to wash and set the table.
      1. Add the booth parameter to the server's SetTable method, as shown in the class diagram below.
      2. 3.2 Restaurant - class diagram for adding booth parameters
      3. In the restaurant's SetUpTable method, pass the restaurant's Booth field as the parameter when calling the SetTable method. The updated method call is shown in the sequence diagram below.
      4. 3.2 Restaurant - sequence diagram for passing booth parameter
      5. In the SetTable method, call the WashTable and SetTable methods on the booth parameter, as shown in the sequence diagram above.
    2. Add booth access to fill condiments.
      1. Add the booth parameter to the server's FillCondiments method, as shown in the class diagram above.
      2. In the restaurant's SetUpTable method, pass the restaurant's Booth field as the parameter when calling the FillCondiments method. The updated method call is shown in the sequence diagram above.
      3. In the server's FillCondiments method, call the FillCondiments on the booth parameter, as shown in the sequence diagram above.
    3. Ensure that all code is StyleCop compliant.
    4. Check your work:
      1. Set a breakpoint in the restaurant's SetUpTable method on the line that calls the SetTable method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, set up table button.
      4. Press F11 to step into the SetTable method. Ensure that the booth parameter is the restaurant's booth object.
      5. Press F11 to step first into the WashTable and then the SetTable methods. Ensure that the object you step into is the restaurant's booth object. Press F11 to return to the SetUpTable method.
      6. Press F11 to step into the FillCondiments method. Ensure that the booth parameter is the restaurant's booth object.
      7. Press F11 to step into the booth's FillCondiments method. Ensure that the object you stepped into is the restaurant's booth object.
  11. Use the patron as a parameter
  12. The server needs access to the regular patron in order to seat him in his booth. In this task, you will add a parameter to the SeatPatron method and then use that parameter. You will check your work by setting a breakpoint, stepping into the method calls, and ensuring that you step into the correct objects.

    1. Define the Sit method on the Patron class as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding sit method to patron
    3. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
    4. Add the patron parameter to the server's SeatPatron method, as shown in the class diagram below.
    5. 3.2 Restaurant - class diagram for adding parameter to seat patron method
    6. In the restaurant's SeatTheRegular method, pass TheRegular field as the parameter when calling the server's SeatPatron method. The updated method call is shown in the sequence diagram below.
    7. 3.2 Restaurant - sequence diagram for calling seat patron method with parameter
    8. In the SeatPatron method, call the Sit method on the patron parameter, as shown in the sequence diagram above.
    9. Ensure that all code is StyleCop compliant.
    10. Check your work:
      1. Set a breakpoint in the restaurant's SeatTheRegular method on the line that calls the SeatPatron method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, seat the regular button.
      4. Press F11 to step into the SeatPatron method. Ensure that the patron parameter is the restaurant's TheRegular object.
      5. Press F11 to step into the Sit method. Ensure that the object you stepped into is the restaurant's TheRegular object.
  13. Give the patron a coat
  14. The patron has worn a coat the restaurant and wants to hang it up before eating. In this task, you will define a coat class, give the patron a coat field, and define a method for hanging up the coat. You will check your work by setting a breakpoint, stepping into the method calls, and ensuring that you step into the correct object.

    1. Create a new class called Coat in the Business Classes folder and define it as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for coat class
    3. Add the Coat field to the Patron class, as shown in the class diagram above.
    4. Define the Coat field and the HangCoat method on the Booth class, as shown in the class diagram above.
    5. Check your work: Build the solution and ensure that the code compiles without errors or warnings.
    6. Create a coat for the regular.
      1. In the newRestaurantButton_Click, create a new instance of the Coat class and assign it to the TheRegular's Coat field. Put this line of code immediately above the line that sets TheRegular's favorite drink name.
      2. Underneath the code that sets the TheRegular's fields, write the following code comment:
      3. // Set field values of the regular's coat.
      4. Underneath the code comment, set the values of the coat's fields to the values specified in the object diagram below.
      5. 3.2 Restaurant - object diagram for coat fields
    7. Ensure that all code is StyleCop compliant.
    8. Check your work:
      1. Set a breakpoint in the newRestaurantButton_Click on the line that instantiates the regular's coat.
      2. Start the application.
      3. Click the New restaurant button.
      4. Press F10 to step over the line that instantiates the Coat field. Ensure that the coat is instantiated correctly.
      5. Press F10 to step over the lines of code that set the coat's field values. Ensure that the value of each field is set correctly.
  15. Give the server access to the booth to seat a patron
  16. The server needs access to the booth in addition to the patron in order to seat him. In this task, you will add a booth parameter to the SeatPatron method. You will check your work by setting a breakpoint, stepping into the method call, and ensuring that the parameter contains the correct object.

    1. Add the booth parameter to the SeatPatron method as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding booth parameter to seat patron method
    3. In the restaurant's SeatTheRegular method, pass in the restaurant's Booth field as the second parameter to the SeatPatron method. The updated method call is shown in the sequence diagram below.
    4. 3.2 Restaurant - sequence diagram for calling seat patron method with booth parameter
    5. Ensure that all code is StyleCop compliant.
    6. Check your work:
      1. Set a breakpoint in the restaurant's SeatTheRegular method on the line that calls the SeatPatron method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, seat the regular button.
      4. Press F11 to step into the SeatPatron method. Ensure that the patron parameter is the restaurant's TheRegular object and that the booth parameter is the restaurant's Booth object.
  17. Add a parameter to allow patron to hang his coat
  18. The patron needs access to the booth in order to hang up his coat. In this task, you will add a parameter to the Sit method and call the HangCoat method. You will check your work by setting a breakpoint, stepping into the method calls, and ensuring that the parameters are the correct objects and the methods are called correctly.

    1. Add the booth parameter to the patron's Sit method, as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding booth parameter to sit method
    3. Add the Booth field to the Patron class, as shown in the class diagram above.
    4. In the server's SeatPatron method, pass the booth parameter as the parameter to the Sit method. The updated method call is shown in the sequence diagram below.
    5. 3.2 Restaurant - sequence diagram for calling sit method with booth parameter
    6. In the patron's Sit method, set the Booth field to the booth parameter. Then set the booth's IsOccupied field to true.
    7. Note: This code sets the patron's booth to the booth in which he sat down, and then it notifies the booth that it is now occupied.

    8. In the patron's Sit method, call the HangCoat method on the booth parameter, as shown in the sequence diagram above.
    9. Ensure that all code is StyleCop compliant.
    10. Check your work:
      1. Set a breakpoint in the server's SeatPatron method on the line that calls the Sit method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, seat the regular button.
      4. Press F11 to step into the Sit method. Ensure that the booth parameter is the restaurant's Booth object.
      5. Press F11 to step into the HangCoat method. Ensure that you stepped into the restaurant's Booth object.
  19. Use a parameter to hang the patron's coat
  20. The booth needs to accept the patron's coat in order to store it on a hanger. In this task, you will add a parameter to the HangCoat method. You will check your work by setting a breakpoint, stepping into the method call, and ensuring that the parameter is the correct object.

    1. Add the coat parameter to the booth's HangCoat method, as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding parameter to hang coat method
    3. In the HangCoat method, set the Coat field to the coat parameter.
    4. In the patron's Sit method, pass the patron's Coat field as the parameter to the HangCoat method. The updated method call is shown in the sequence diagram below.
    5. 3.2 Restaurant - sequence diagram for calling hang coat method with parameter
    6. Ensure that all code is StyleCop compliant.
    7. Check your work:
      1. Set a breakpoint in the patron's Sit method on the line that calls the HangCoat method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Heidi, seat the regular button.
      4. Press F11 to step into the HangCoat method. Ensure that the coat parameter is the patron's coat object.
  21. Add parameters to the WaitTable method
  22. In order to wait a table, the server needs give the patron a menu and communicate with the cook. In this task, you will add several parameters to the server's WaitTable method. You will check your work by setting a breakpoint, stepping into the method call, and ensuring that the parameters contain the correct objects.

    1. Add the cook, menu, and patron parameters to the WaitTable method, as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding parameters to the wait table method
    3. In the restaurant's TendToTheRegular method, pass the restaurant's Owner field, the LunchMenu field, and the TheRegular field as the parameters into the WaitTable method. The updated method call is shown in the sequence diagram below.
    4. 3.2 Restaurant - sequence diagram for calling the wait table method with parameters
    5. Ensure that all code is StyleCop compliant.
    6. Check your work:
      1. Set a breakpoint in the restaurant's TendToTheRegular method on the line that calls the WaitTable method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Serve lunch to the regular button.
      4. Press F11 to step into the WaitTable method call. Ensure that the cook parameter is the restaurant's owner, that the menu parameter is the restaurant's lunch menu, and that the patron parameter is the restaurant's regular.
  23. Define and use a class for menu items
  24. The restaurant needs menu items for the patron and server to reference when requesting food and drink. In this task, you will define a class to represent menu items and instantiate items for the lunch menu. You will check your work by setting a breakpoint, stepping through the code, and ensuring that the objects are instantiated correctly.

    1. Create a new class called MenuItem in the Business Classes folder and define it as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for menu item class
    3. Add the Drink and Entree fields to the Menu class, as shown in the class diagram above.
    4. Create instances of the drink and entree menu items and assign them to the menu's fields.
      1. In the newRestaurantButton_Click, instantiate the lunch menu's Drink and Entree fields to new instances of the MenuItem class. Put these lines of code immediately below the line that sets the lunch menu's color.
      2. Set fields of the lunch menu's drink.
        1. Underneath the code that sets the lunch menu's field values, write the following code comment:
        2. // Set the field values of the lemonade.
        3. Underneath the code comment, set the values of the drink's fields to the values specified in the object diagram below.
        4. 3.2 Restaurant - object diagram for setting menu item field values
      3. Set field values of the lunch menu's entree.
        1. Underneath the code that sets the lemonade's field values, write the following code comment:
        2. // Set field values of the turkey club.
        3. Underneath the code comment, set the values of the entree's fields to the values specified in the object diagram above.
    5. Ensure that all code is StyleCop compliant.
    6. Check your work:
      1. Set a breakpoint in the newRestaurantButton_Click on the line that instantiates the lunch menu's Drink field.
      2. Start the application.
      3. Click the New restaurant button.
      4. Press F10 to step over the lines of code that instantiate the Drink and Entree fields. Ensure that each field is instantiated correctly.
      5. Press F10 to step over the lines of code that set the field values of the lunch menu's drink and entree. Ensure that the value of each field is set correctly.
  25. Add methods for making food items
  26. The server needs to request food items to be prepared by the cook. In this task, you will define and call methods for filling an order and making the food items based on ordered menu items. You will check your work by setting a breakpoint, stepping into the method calls, and ensuring that the methods are called correctly and the parameters are the correct objects.

    1. Define the methods on the Cook and Server classes as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding methods for making food items
    3. From the server's WaitTable method, call the methods as shown in the sequence diagram. Pass the cook and menu parameters as the parameters to the TakeAndFillOrder method. Pass the menu's Drink field as the parameter to the MakeFoodItem method.
    4. 3.2 Restaurant - sequence diagram for calling methods for making food items
    5. Ensure that all code is StyleCop compliant.
    6. Check your work:
      1. Set a breakpoint in the server's WaitTable method on the line that calls the TakeAndFillOrder method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Serve lunch to the regular button.
      4. Press F11 to step into the TakeAndFillOrder method. Ensure that the cook parameter is the restaurant's owner object and that the menu parameter is the restaurant's lunch menu object.
      5. Press F11 to step into the MakeFoodItem method. Ensure that the object you stepped into the restaurant's owner, and that the menuItem parameter is the lunch menu's drink item.
  27. Define and call methods for the patron to eat his meal
  28. The regular patron's meal is ready to eat and he needs methods to consume the meal. In this task, you will define and call methods for use in having the patron eat his meal. You will check your work by setting a breakpoint, stepping into the method calls, and ensuring that you stepped into the correct object and that the methods were called correctly.

    1. Define the methods on the Patron class as shown in the class diagram below.
    2. 3.2 Restaurant - class diagram for adding consume methods to patron class
    3. From the server's WaitTable method, call the methods as shown in the sequence diagram below.
    4. 3.2 Restaurant - sequence diagram for calling consume methods
    5. In the EnjoyMeal method, after calling the Consume method, set the Booth field's IsOccupied field to false and then set the Booth field to null.
    6. Note: This code represents the patron getting up and leaving the booth after finishing his meal, meaning that the booth is no longer occupied.

    7. Check your work:
      1. Set a breakpoint in the server's WaitTable method on the line that calls the EnjoyMeal method.
      2. Start the application.
      3. Click the New restaurant button. Then click the Serve lunch to the regular button.
      4. Press F11 to step into the EnjoyMeal method. Ensure that the object you stepped into is the restaurant's regular patron.
      5. Press F11 to step into the Consume method. Ensure that you remain in the Patron.cs file and the current object remains the restaurant's regular patron.
  29. Submit a zipped Visual Studio solution by completing the following.
    1. Build the application and ensure that it has no compiler errors or warnings.
    2. Ensure that all code is StyleCop compliant.
    3. Browse to the project folder and add it to a newly created zipped archive.
    4. Submit the zipped project folder to the correct assignment in Blackboard.