Advertisement
TankorSmash

Untitled

Aug 13th, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1.         private static KeyValuePair<string, string> getUserAction(string choices)
  2.         {
  3.             //whether or not the userAction is valid
  4.             bool actionIsValid = false;
  5.  
  6.             //From the choices string, parse out the optional actions, returned as a key:action
  7.             Dictionary<string, string> validAnwers = FindActionKeys(choices);
  8.  
  9.             do
  10.             {
  11.                 //Get the user's choice of action
  12.                 string action = Tools.Prompt("What do you want to do?\n{0}", choices);
  13.  
  14.                 //Verify that it's in the keys of the validAnswers
  15.                 if (validAnwers.ContainsKey(action))
  16.                 {
  17.                     //Tools.Print("you have chosen wisely and a valid key.\n\n");
  18.                     //Tools.Print(validAnwers[action]);
  19.                     //return action;
  20.                     return new KeyValuePair<string, string>(action, validAnwers[action]);
  21.                 }
  22.                 else
  23.                 {
  24.                     Tools.Print(newFG: ConsoleColor.Red,
  25.                                 text: "Incorrect key, please type exactly the letter you're looking for.\n");
  26.                     //return action;
  27.                 }
  28.             } while (!actionIsValid);
  29.  
  30.             //since the loop is done, the action is considered valid, and returned
  31.             //return action;
  32.             return new KeyValuePair<string, string>("invalid", "invalid");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement