Advertisement
lilflamekid91

Lab 3 - Shell Game

May 23rd, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. public class ShellGame extends Lab3{
  4.  
  5. private int peanut;
  6. private double gamesplayed=0;
  7. public double Wins=0;
  8. public int Losses=0;
  9. public double winrate;
  10.  
  11. public void HidePeanut()
  12.  
  13. {
  14. Random r = new Random();
  15. peanut = r.nextInt(3)+1;
  16. }
  17.  
  18. public void ShowShells()
  19.  
  20. {
  21. System.out.println(" __ __ __");
  22. System.out.println(" // \\ // \\ // \\");
  23. System.out.println("// 1 \\ // 2 \\ // 3 \\");
  24. System.out.println("");
  25. System.out.println("Where's the Peanut?");
  26. System.out.println("");
  27. }
  28.  
  29.  
  30. public int GetPeanut()
  31.  
  32. {
  33. return (peanut);
  34. }
  35.  
  36. public void GamesPlayed()
  37.  
  38. {
  39. gamesplayed++;
  40. }
  41.  
  42. public double GetGP()
  43. {
  44. return (gamesplayed);
  45. }
  46.  
  47. public void Winner()
  48. {
  49. Wins++;
  50. }
  51. public void Loser()
  52. {
  53. Losses++;
  54. }
  55.  
  56. public void ShowPeanut()
  57.  
  58. {
  59. if (peanut==1)
  60. {
  61. System.out.println(" __ __ __");
  62. System.out.println(" // \\ // \\ // \\");
  63. System.out.println("// # \\ // \\ // \\");
  64. }
  65. else if (peanut==2)
  66. {
  67. System.out.println(" __ __ __");
  68. System.out.println(" // \\ // \\ // \\");
  69. System.out.println("// \\ // # \\ // \\");
  70. }
  71. else if (peanut==3)
  72. {
  73. System.out.println(" __ __ __");
  74. System.out.println(" // \\ // \\ // \\");
  75. System.out.println("// \\ // \\ // # \\");
  76. }
  77.  
  78.  
  79. }
  80.  
  81. public void DisplayStats()
  82. {
  83. winrate=Wins/gamesplayed*100;
  84. System.out.println("Statistics");
  85. System.out.println("Games Played: " +(int)gamesplayed);
  86. System.out.println("Games Won: " + (int)Wins);
  87. System.out.println("Games Lost: " + Losses);
  88. System.out.println("You won "+(int)winrate+"% of the Games");
  89. }
  90.  
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement