Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace prac6_Q2
- {
- class menu
- {
- static void Main(string[] args)
- {
- int response = 0;
- string tempVal = "";
- bool parseAttempt = false;
- while (response != 4)
- {
- // Display the menu
- Console.WriteLine("1. Make a phone call");
- Console.WriteLine("2. Send an SMS");
- Console.WriteLine("3. Find a contact");
- Console.WriteLine("4. Quit");
- Console.Write("Enter your selection > ");
- // Get the users response
- tempVal = Console.ReadLine();
- parseAttempt = Int32.TryParse(tempVal, out response);
- if (parseAttempt == false)
- {
- response = 0;
- }
- // Process the response
- switch (response)
- {
- case 1:
- Console.WriteLine("User selected to make a phone call, option " + response);
- break;
- case 2:
- Console.WriteLine("User selected to send an SMS, option " + response);
- break;
- case 3:
- Console.WriteLine("User selected to find a contact, option " + response);
- break;
- case 4:
- Console.WriteLine("User selected to Quit, option " + response);
- break;
- default:
- Console.WriteLine("Unknown selection, option " + response);
- break;
- }
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement