Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- public class ShellGame extends Lab3{
- private int peanut;
- private double gamesplayed=0;
- public double Wins=0;
- public int Losses=0;
- public double winrate;
- public void HidePeanut()
- {
- Random r = new Random();
- peanut = r.nextInt(3)+1;
- }
- public void ShowShells()
- {
- System.out.println(" __ __ __");
- System.out.println(" // \\ // \\ // \\");
- System.out.println("// 1 \\ // 2 \\ // 3 \\");
- System.out.println("");
- System.out.println("Where's the Peanut?");
- System.out.println("");
- }
- public int GetPeanut()
- {
- return (peanut);
- }
- public void GamesPlayed()
- {
- gamesplayed++;
- }
- public double GetGP()
- {
- return (gamesplayed);
- }
- public void Winner()
- {
- Wins++;
- }
- public void Loser()
- {
- Losses++;
- }
- public void ShowPeanut()
- {
- if (peanut==1)
- {
- System.out.println(" __ __ __");
- System.out.println(" // \\ // \\ // \\");
- System.out.println("// # \\ // \\ // \\");
- }
- else if (peanut==2)
- {
- System.out.println(" __ __ __");
- System.out.println(" // \\ // \\ // \\");
- System.out.println("// \\ // # \\ // \\");
- }
- else if (peanut==3)
- {
- System.out.println(" __ __ __");
- System.out.println(" // \\ // \\ // \\");
- System.out.println("// \\ // \\ // # \\");
- }
- }
- public void DisplayStats()
- {
- winrate=Wins/gamesplayed*100;
- System.out.println("Statistics");
- System.out.println("Games Played: " +(int)gamesplayed);
- System.out.println("Games Won: " + (int)Wins);
- System.out.println("Games Lost: " + Losses);
- System.out.println("You won "+(int)winrate+"% of the Games");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement