Advertisement
Dakpluto

SlotMachine.java

Oct 23rd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. public class SlotMachine {
  2.     private String name;
  3.     private int currentSpin;
  4.     private int jackpotSpin;
  5.     private int jackpotPayout;
  6.  
  7.     private static int totalSpins = 0;
  8.  
  9.     public SlotMachine(String name, int currentSpin, int jackpotSpin,
  10.             int jackpotPayout) {
  11.         this.name = name;
  12.         this.currentSpin = currentSpin;
  13.         this.jackpotSpin = jackpotSpin;
  14.         this.jackpotPayout = jackpotPayout;
  15.     }
  16.  
  17.     public static int getTotalSpins() {
  18.         return totalSpins;
  19.     }
  20.  
  21.     public static void setTotalSpins(int totalSpins) {
  22.         SlotMachine.totalSpins = totalSpins;
  23.     }
  24.  
  25.     public String getName() {
  26.         return name;
  27.     }
  28.  
  29.     public void setName(String name) {
  30.         this.name = name;
  31.     }
  32.  
  33.     public int getCurrentSpin() {
  34.         return currentSpin;
  35.     }
  36.  
  37.     public void setCurrentSpin(int currentSpin) {
  38.         this.currentSpin = currentSpin;
  39.     }
  40.  
  41.     public int getJackpotSpin() {
  42.         return jackpotSpin;
  43.     }
  44.  
  45.     public void setJackpotSpin(int jackpotSpin) {
  46.         this.jackpotSpin = jackpotSpin;
  47.     }
  48.  
  49.     public int getJackpotPayout() {
  50.         return jackpotPayout;
  51.     }
  52.  
  53.     public void setJackpotPayout(int jackpotPayout) {
  54.         this.jackpotPayout = jackpotPayout;
  55.     }
  56.  
  57.     public void play(Player player) {
  58.         player.playMachine(-1);
  59.         this.currentSpin += 1;
  60.         SlotMachine.totalSpins += 1;
  61.         if (this.currentSpin == this.jackpotSpin) {
  62.             player.winJackpot(this.jackpotPayout);
  63.             this.currentSpin = 0;
  64.         }
  65.     }
  66.  
  67.     public String toString() {
  68.         return "SlotMachine [name=" + name + ", currentSpin=" + currentSpin
  69.                 + ", jackpotSpin=" + jackpotSpin + ", jackpotPayout="
  70.                 + jackpotPayout + "]";
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement