Advertisement
lilflamekid91

Lab 3 - Main Class

May 23rd, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. /*Steven Lam
  2. * February 13, 2013
  3. * Purpose: To take User's input and play the shell game
  4. * Input: User: Do you want to play, Where's the peanut
  5. * Output: Where's the peanut, did you win or lose, User statistics
  6. */
  7.  
  8. import java.util.*;
  9. public class Lab3 {
  10.  
  11. public static void main(String[] Args){
  12.  
  13. int input;
  14. int Game;
  15. Scanner keyboard = new Scanner(System.in);
  16.  
  17. ShellGame g = new ShellGame();
  18. System.out.println();
  19. System.out.println("Welcome to the Shell Game!");
  20. System.out.println();
  21. System.out.println("Main Menu");
  22. System.out.println("--------------------------");
  23. System.out.println();
  24. System.out.println("1) Play the Shell Game");
  25. System.out.println();
  26. System.out.println("2) Exit");
  27. System.out.println();
  28. System.out.println("--------------------------");
  29. System.out.println();
  30. Game = keyboard.nextInt();
  31. while (Game==1)
  32. {
  33. g.HidePeanut();
  34. g.ShowShells();
  35. g.GamesPlayed();
  36. input=keyboard.nextInt();
  37. System.out.println("Peanut is : "+g.GetPeanut());
  38. System.out.println("");
  39. if (input==g.GetPeanut())
  40. {
  41. g.Winner();
  42. System.out.println("Congratulations! You Won!");
  43. System.out.println("Here is the Peanut:");
  44. g.ShowPeanut();
  45.  
  46. }
  47. else if (input!=g.GetPeanut())
  48. {
  49. g.Loser();
  50. System.out.println("Sorry You Lost!");
  51. System.out.println("Here is the Peanut:");
  52. g.ShowPeanut();
  53. }
  54.  
  55.  
  56.  
  57.  
  58. System.out.println("");
  59. System.out.println("--------------------------");
  60. System.out.println("Do you want to play again?");
  61. System.out.println("1)Yes 2)No");
  62. System.out.println("--------------------------");
  63. Game = keyboard.nextInt();
  64. }
  65.  
  66. System.out.println("Thank you for playing, Here is your Statistics");
  67. System.out.println("");
  68. g.DisplayStats();
  69.  
  70.  
  71.  
  72.  
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement