Guest User

Untitled

a guest
Jul 29th, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. Flow of program not what was expected
  2. public static void SetUpCoins() {
  3. coin1 = new Coin();
  4. coin2 = new Coin();
  5. }
  6.  
  7. public static void PlayConsole() {
  8. SetUpCoins();
  9. OutputWinner();
  10. }
  11.  
  12.  
  13. public static void OutputWinner() {
  14.  
  15. if (coin1.ToString() == "Heads" && coin2.ToString() == "Heads") {
  16. Console.WriteLine("You threw Heads - you win");
  17. ++point_player;
  18. } else if (coin1.ToString() == "Tails" && coin2.ToString() == "Tails") {
  19. Console.WriteLine("You threw Tails - I win");
  20. ++point_comp;
  21. } else {
  22. Console.WriteLine("You threw Odds");
  23. WaitForKey_ConsoleOnly("Press any key to throw again");
  24. PlayConsole();
  25. }
  26.  
  27. Console.WriteLine("You have {0} points and the computer has {1} points", point_player, point_comp);
  28.  
  29. if (WantToPlayAgain_ConsoleOnly()) { // ask user if they want to play again; return bool
  30. PlayConsole();
  31. }
  32. }
  33.  
  34. private static bool WantToPlayAgain_ConsoleOnly() {
  35. string input;
  36. bool validInput = false;
  37. do {
  38. Console.Write("Play Again? (Y or N): ");
  39. input = Console.ReadLine().ToUpper();
  40. validInput = input == "Y" || input == "N";
  41. } while (!validInput);
  42.  
  43. return input == ("Y");
  44. }
  45.  
  46. public static void OutputWinner() {
  47. do {
  48. // Game code
  49. }
  50. while (WantToPlayAgain_ConsoleOnly());
  51. }
Advertisement
Add Comment
Please, Sign In to add comment