Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static KeyValuePair<string, string> getUserAction(string choices)
- {
- //whether or not the userAction is valid
- bool actionIsValid = false;
- //From the choices string, parse out the optional actions, returned as a key:action
- Dictionary<string, string> validAnwers = FindActionKeys(choices);
- do
- {
- //Get the user's choice of action
- string action = Tools.Prompt("What do you want to do?\n{0}", choices);
- //Verify that it's in the keys of the validAnswers
- if (validAnwers.ContainsKey(action))
- {
- //Tools.Print("you have chosen wisely and a valid key.\n\n");
- //Tools.Print(validAnwers[action]);
- //return action;
- return new KeyValuePair<string, string>(action, validAnwers[action]);
- }
- else
- {
- Tools.Print(newFG: ConsoleColor.Red,
- text: "Incorrect key, please type exactly the letter you're looking for.\n");
- //return action;
- }
- } while (!actionIsValid);
- //since the loop is done, the action is considered valid, and returned
- //return action;
- return new KeyValuePair<string, string>("invalid", "invalid");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement