/// <summary> /// display a list of product types and return the selected product with cost /// </summary> public void DisplayProductUserSelection(Salesperson salesperson) { bool usingMenu = true; int maxAttempts = 3; bool maxAttemptsExceeded = false; Product product = new Product(); Product.ProductType productType = new Product.ProductType(); productType = Product.ProductType.None; // // set up display area // ConsoleUtil.DisplayReset(); ConsoleUtil.HeaderText = "Select a Product"; Console.CursorVisible = false; while (usingMenu) { // // set up display area // ConsoleUtil.DisplayReset(); Console.CursorVisible = false; // // display the menu // ConsoleUtil.DisplayMessage("Please type the number of your menu choice."); ConsoleUtil.DisplayMessage(""); Console.Write( "\t" + "1. Furry" + Environment.NewLine + "\t" + "2. Spotted" + Environment.NewLine + "\t" + "3. Dancing" + Environment.NewLine); // // get and process the user's response // note: ReadKey argument set to "true" disables the echoing of the key press // ConsoleKeyInfo userResponse = Console.ReadKey(true); switch (userResponse.KeyChar) { case '1': productType = Product.ProductType.Furry; usingMenu = false; break; case '2': productType = Product.ProductType.Spotted; usingMenu = false; break; case '3': productType = Product.ProductType.Dancing; usingMenu = false; break; default: ConsoleUtil.DisplayMessage( "It appears you have selected an incorrect choice." + Environment.NewLine + "Press any key to continue."); userResponse = Console.ReadKey(true); if (userResponse.Key == ConsoleKey.Escape) { usingMenu = false; } break; } product.Type = productType; } Console.Clear(); if (!string.IsNullOrEmpty(product.Type.ToString())) { product.Cost = ConsoleValidator.TestForDouble(maxAttempts, $"{product.Type} Product Cost:", out maxAttemptsExceeded); } Console.CursorVisible = true; salesperson.CurrentStock = product; //return product; }