- Getting Started
- Download this 1.2Restaurant zip file.
1.2 Restaurant starting code (download)
Warning: This starting code is intended for use with Visual Studio 2015 or later. If you have an earlier version of Visual Studio, please upgrade to 2015. If you need to use an earlier version of Visual Studio, you may need to change project settings (e.g. TargetFrameworkVersion) in the provided starting code.
- Extract the contents of the zip file to a location of your choice.
- Rename the OOP 1 Restaurant 1.2 LastName folder, replacing LastName with your last name.
- Within the folder rename the OOP 1 Restaurant 1.2 LastName .sln file with your last name.
- Using Visual Studio
Use Visual Studio to create a New restaurant button click event handler. Set a breakpoint in the event handler and ensure that the code is hit.
- Open the renamed file OOP 1 Restaurant 1.2 Last Name.sln contained within the renamed folder.
Warning: Make sure that you are opening the .sln file inside the extracted folder. Visual Studio solutions are made up of multiple files, and the .sln file cannot find the other required files if it is opened from inside a compressed, or zipped, folder.
- Double-click on MainWindow.xaml in the Solution Explorer.
- Select the New restaurant button by single-clicking it.
- Navigate to the Properties Window.
- Change the Properties Window to show events (click on its lightning bolt icon).
- Double-click on the Click event. This should open a new tab called MainWindow.xaml.cs and take you to this assignment's button-click event handler.
- Check your work:
- Set a breakpoint at the opening curly brace of the newRestaurantButton_Click.
- Start the application by clicking the Start button in the top toolbar.
- Click the New restaurant button and ensure that the event handler code is hit.
- Stop the application by clicking the red square in the top toolbar or pressing Shift + F5.
- Create Mom's restaurant
The application needs a restaurant object to be instantiated. In this task, you will create a restaurant instance and assign it to a variable. You will check your work by making sure the restaurant is instantiated without errors.
- Add the following code comment to the beginning of newRestaurantButton_Click method.
// Create an instance of the Restaurant class.
- Define a variable named moms and set it to a new instance of the Restaurant class, as shown in the object diagram below.

- Check your work:
- Start the application.
- Click the New restaurant button.
- Press F10 to step through each line of code. Ensure that the moms variable is instantiated.
- Stop the application.
- Set the capacity of Mom's
Now that Mom's has been instantiated, it needs a value for its capacity. In this task, you will assign an integer value to Mom's Capacity field. You will check your work by setting a breakpoint, stepping over the code that sets the capacity, and ensuring that the field is set correctly.
- Underneath the code that instantiates the restaurant, write the following code comment:
// Set field values of Moms.
- Set moms' Capacity field to a value of 25, as shown in the object diagram below.

- Check your work:
- Start the application.
- Click the New restaurant button.
- Press F10 to step through the code. Step over the line of code that instantiates moms. Step over the line of code that sets the Capacity field. Ensure that the field value is set to 25.
- Stop the application and remove the breakpoint.
- Set Mom's dinner menu
Mom's also has a dinner menu that needs to be instantiated. In this task, you will create an instance of the Menu class and assign it to the restaurant's DinnerMenu field. You will check your work by setting a breakpoint, stepping through the code, and ensuring that the DinnerMenu field is instantiated correctly.
- Create a Menu instance and assign it to the restaurant's DinnerMenu field, as shown in the object diagram below. Put this line of code below the line that sets the restaurant's capacity.

- Check your work:
- Set a breakpoint in the newRestaurantButton_Click on the line that instantiates the DinnerMenu field.
- Start the application.
- Click the New restaurant button.
- Press F10 to step over the line of code that instantiates the DinnerMenu field. Ensure that the field is instantiated correctly.
- Stop the application and remove the breakpoint.
- Set the restaurant's remaining fields
Mom's has other fields that need to be set, including its name, a lunch menu, and its owner. In this task, you will assign the specified value or object to each field. You will check your work by setting a breakpoint, stepping through the code, and ensuring that each field is set or instantiated correctly.
- Create a Menu instance and assign it to the restaurant's LunchMenu field, as shown in the object diagram below.

- Set the restaurant's Name field to a string of "Mom's", as shown in the object diagram above.
- Create a Cook instance and assign it to the restaurant's Owner field, as shown in the object diagram above.
- Check your work:
- Set a breakpoint in the newRestaurantButton_Click on the line that sets the Name field.
- Start the application.
- Click the New restaurant button.
- Press F10 to step over the lines of code that set the Name, LunchMenu, and Owner fields. Ensure that each of the fields is set or instantiated correctly.
- Stop the application and remove the breakpoint.
- Set DinnerMenu fields
The restaurant's dinner menu has fields that need to be set. In this task, you will set each field to the specified value. You will check your work by setting a breakpoint, stepping through the code, and ensuring that the dinner menu is instantiated and all of its fields are set to the correct values.
- Underneath the code that sets moms' fields, write the following code comment:
// Set field values of the dinner menu.
- Underneath the code comment, set the dinner menu's fields as shown in the object diagram below.

- Check your work:
- Set a breakpoint in the newRestaurantButton_Click on the line of code that sets the dinner menu's color.
- Start the application.
- Click the New restaurant button.
- Press F10 to step over the lines of code that set the dinner menu's fields. Ensure that each field is set correctly.
- Stop the application and remove the breakpoint.
- Set LunchMenu and Owner fields
The restaurant contains two other objects - the lunch menu and the owner - with fields that need to be set. In this task, you will assign the specified value to each field in the LunchMenu field and the Owner field. You will check your work by setting a breakpoint, stepping through the code, and ensuring that all of the fields of the lunch menu and owner are set correctly.
- Set the fields of the lunch menu.
- Underneath the code that sets the dinner menu's fields, write the following code comment:
// Set field values of the lunch menu.
- Underneath the code comment, set the values of the lunch menu's fields to the values specified in the object diagram below.

- Set the fields of the owner.
- Underneath the code that sets the dinner menu's fields, write the following code comment:
// Set field values of the owner.
- Underneath the code comment, set the values of the owner's fields to the values specified in the object diagram above.
- Check your work:
- Set a breakpoint in the newRestaurantButton_Click on the line that sets the color of the lunch menu.
- Start the application.
- Click the New restaurant button.
- Press F10 to step over the lines of code that set the fields of the lunch menu and the owner. Ensure that each field value is set or instantiated correctly.
- Stop the application and remove the breakpoint.
- Set BreadOven fields
There is one last object, the owner's bread oven, that has fields that need to be set. In this task, you will assign the specified value to each of the bread oven's fields. You will check your work by setting a breakpoint, stepping through the code, and ensuring that all of the bread oven's fields are set to the correct values.
- Underneath the code that sets the owner's fields, write the following code comment:
// Set field values of the owner's bread oven.
- Underneath the code comment, set the values of the bread oven's fields to the values specified in the object diagram below.

- Check your work:
- Set a breakpoint in the newRestaurantButton_Click on the line that sets the bread oven's BreadstickBatchSize field.
- Start the application.
- Click the New restaurant button.
- Press F10 to step over the lines of code that set the bread oven's fields. Ensure that each field is set to the correct value.
- Stop the application and remove the breakpoint.
- Submit a zipped Visual Studio solution by completing the following.
- Build the application and ensure that it has no compiler errors or warnings.
- Ensure that all code is StyleCop compliant.
- Browse to the project folder and add it to a newly created compressed, or zipped, archive.
- Submit the compressed, or zipped, project folder to the correct assignment in Blackboard.