static void Main(string[] args) { //Variable Declarations string userInput = ""; int menuChoice = 0; int subChoice = 0; Stack <string> myStack = new Stack <string>(); Queue <string> myQueue = new Queue <string>(); Dictionary <string, int> myDictionary = new Dictionary <string, int>(); do { //Display the menu Console.WriteLine("1. Stack"); Console.WriteLine("2. Queue"); Console.WriteLine("3. Dictionary"); Console.WriteLine("4. Exit\n"); //Get the menu choice from the user userInput = Console.ReadLine(); menuChoice = CheckNums(userInput); Console.WriteLine(); //Given the menu choice, a switch will show the menu for each data structure switch (menuChoice) { case 1: //Stack ManipulateStructure handleStack = new ManipulateStructure(); subChoice = 0; //Remains in stack menu until they select to return to the main menu while (subChoice != 7) { //Retrieves menu choice from the stack menu subChoice = handleStack.Menu("Stack"); //Goes to that particular menu item for the stack manipulation handleStack.modifyStack(subChoice, myStack); } break; case 2: //Queue ManipulateStructure handleQueue = new ManipulateStructure(); subChoice = 0; //Remains in queue menu until they select to return to the main menu while (subChoice != 7) { //Retrieves menu choice from the queue menu subChoice = handleQueue.Menu("Queue"); //Goes to that particular menu item for the queue manipulation handleQueue.modifyQueue(subChoice, myQueue); } break; case 3: //Dictionary ManipulateStructure handleDictionary = new ManipulateStructure(); subChoice = 0; //Remains in dictionary menu until they select to return to the main menu while (subChoice != 7) { //Retrieves menu choice from the dictionary menu subChoice = handleDictionary.Menu("Dictionary"); //Goes to that particular menu item for the dictionary manipulation handleDictionary.modifyDictionary(subChoice, myDictionary); } break; case 4: //Exit Console.WriteLine("Goodbye!"); break; default: //Invalid menu number Console.WriteLine("Please choose one of the menu options"); break; } } while (menuChoice != 4); }
static void Main(string[] args) { string userInput = ""; int menuChoice = 0; int subChoice = 0; Stack <string> myStack = new Stack <string>(); Queue <string> myQueue = new Queue <string>(); Dictionary <string, int> myDictionary = new Dictionary <string, int>(); do { Console.WriteLine("1. Stack"); Console.WriteLine("2. Queue"); Console.WriteLine("3. Dictionary"); Console.WriteLine("4. Exit\n"); userInput = Console.ReadLine(); menuChoice = CheckNums(userInput); Console.WriteLine(); switch (menuChoice) { case 1: ManipulateStructure handleStack = new ManipulateStructure(); subChoice = 0; while (subChoice != 7) { subChoice = handleStack.Menu("Stack"); handleStack.modifyStack(subChoice, ref myStack); } break; case 2: ManipulateStructure handleQueue = new ManipulateStructure(); subChoice = 0; while (subChoice != 7) { subChoice = handleQueue.Menu("Queue"); handleQueue.modifyQueue(subChoice, ref myQueue); } break; case 3: ManipulateStructure handleDictionary = new ManipulateStructure(); subChoice = 0; while (subChoice != 7) { subChoice = handleDictionary.Menu("Dictionary"); handleDictionary.modifyDictionary(subChoice, ref myDictionary); } break; case 4: Console.WriteLine("Goodbye!"); break; default: Console.WriteLine("Please choose one of the menu options"); break; } } while (menuChoice != 4); }