Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SlotMachine {
- private String name;
- private int currentSpin;
- private int jackpotSpin;
- private int jackpotPayout;
- private static int totalSpins = 0;
- public SlotMachine(String name, int currentSpin, int jackpotSpin,
- int jackpotPayout) {
- this.name = name;
- this.currentSpin = currentSpin;
- this.jackpotSpin = jackpotSpin;
- this.jackpotPayout = jackpotPayout;
- }
- public static int getTotalSpins() {
- return totalSpins;
- }
- public static void setTotalSpins(int totalSpins) {
- SlotMachine.totalSpins = totalSpins;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getCurrentSpin() {
- return currentSpin;
- }
- public void setCurrentSpin(int currentSpin) {
- this.currentSpin = currentSpin;
- }
- public int getJackpotSpin() {
- return jackpotSpin;
- }
- public void setJackpotSpin(int jackpotSpin) {
- this.jackpotSpin = jackpotSpin;
- }
- public int getJackpotPayout() {
- return jackpotPayout;
- }
- public void setJackpotPayout(int jackpotPayout) {
- this.jackpotPayout = jackpotPayout;
- }
- public void play(Player player) {
- player.playMachine(-1);
- this.currentSpin += 1;
- SlotMachine.totalSpins += 1;
- if (this.currentSpin == this.jackpotSpin) {
- player.winJackpot(this.jackpotPayout);
- this.currentSpin = 0;
- }
- }
- public String toString() {
- return "SlotMachine [name=" + name + ", currentSpin=" + currentSpin
- + ", jackpotSpin=" + jackpotSpin + ", jackpotPayout="
- + jackpotPayout + "]";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement