Exercise – Build sample data and menu selection loops
In this exercise, you review the code in the Starter project, perform some code clean-up tasks, and then start adding features to your application. The tasks that you complete during this exercise are:
- Code review: review the contents of the Program.cs file.
- Sample data: convert the if-elseif-else structure to switch-case structure that improves readability.
- Menu loop: enclose the main menu and menu item selection in a loop that iterates until the user enters “exit”.
- Menu selections: write the code for a switch-case structure that establishes separate code branches for each menu option.
- Code branches: write placeholder within the menu item branches that provides user feedback until app features are developed.
- Verification test: perform verification tests for the code that you develop in this exercise.
Review the contents of the Program.cs file
In this task, you complete a walkthrough of the Starter project code. The Program.cs file contains a preliminary version of the application that you update during this module. The existing code generates sample data for the application and displays a list of menu options. The menu options represent the main features of your application.
- Ensure that the GuidedProject folder is open in Visual Studio Code.The previous unit includes a Setup section that describes how to open the Starter project. If necessary, go back and follow the Setup instructions.
- In the EXPLORER view, expand the Starter folder, then select Program.cs.When you select the Program.cs file, the file contents open in the Visual Studio Code Editor.If the EXPLORER view isn’t open, select EXPLORER from the Visual Studio Code Activity Bar. The EXPLORER button is at the top of the Activity Bar.
- Take a few minutes to review the code in the Program.cs file.
- Notice that the top portion of your code begins with some variable declarations.