Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Steven Lam
- * February 13, 2013
- * Purpose: To take User's input and play the shell game
- * Input: User: Do you want to play, Where's the peanut
- * Output: Where's the peanut, did you win or lose, User statistics
- */
- import java.util.*;
- public class Lab3 {
- public static void main(String[] Args){
- int input;
- int Game;
- Scanner keyboard = new Scanner(System.in);
- ShellGame g = new ShellGame();
- System.out.println();
- System.out.println("Welcome to the Shell Game!");
- System.out.println();
- System.out.println("Main Menu");
- System.out.println("--------------------------");
- System.out.println();
- System.out.println("1) Play the Shell Game");
- System.out.println();
- System.out.println("2) Exit");
- System.out.println();
- System.out.println("--------------------------");
- System.out.println();
- Game = keyboard.nextInt();
- while (Game==1)
- {
- g.HidePeanut();
- g.ShowShells();
- g.GamesPlayed();
- input=keyboard.nextInt();
- System.out.println("Peanut is : "+g.GetPeanut());
- System.out.println("");
- if (input==g.GetPeanut())
- {
- g.Winner();
- System.out.println("Congratulations! You Won!");
- System.out.println("Here is the Peanut:");
- g.ShowPeanut();
- }
- else if (input!=g.GetPeanut())
- {
- g.Loser();
- System.out.println("Sorry You Lost!");
- System.out.println("Here is the Peanut:");
- g.ShowPeanut();
- }
- System.out.println("");
- System.out.println("--------------------------");
- System.out.println("Do you want to play again?");
- System.out.println("1)Yes 2)No");
- System.out.println("--------------------------");
- Game = keyboard.nextInt();
- }
- System.out.println("Thank you for playing, Here is your Statistics");
- System.out.println("");
- g.DisplayStats();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement