Advertisement
Dakpluto

Casino.java

Oct 23rd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Casino {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.         Scanner playerInput = new Scanner(System.in);
  8.         Scanner slotMachineInput = new Scanner(System.in);
  9.  
  10.         Player margerie = new Player("Margerie", 0);
  11.         SlotMachine[] slotMachines = new SlotMachine[3];
  12.         slotMachines[0] = new SlotMachine("Spinning Wheels", 0, 35, 30);
  13.         slotMachines[1] = new SlotMachine("King Tut's Jackpot Tomb", 0, 100, 60);
  14.         slotMachines[2] = new SlotMachine("Fool's Gold", 0, 10, 11);
  15.  
  16.         System.out.println("How many coins does " + margerie.getName()
  17.                 + " have?");
  18.         margerie.setCoins(playerInput.nextInt());
  19.  
  20.         System.out.println("\nHow many times has " + slotMachines[0].getName()
  21.                 + " played since last jackpot? (Maximum of "
  22.                 + slotMachines[0].getJackpotSpin() + ")");
  23.         slotMachines[0].setCurrentSpin(slotMachineInput.nextInt());
  24.         System.out.println("\nHow many times has " + slotMachines[1].getName()
  25.                 + " played since last jackpot? (Maximum of "
  26.                 + slotMachines[1].getJackpotSpin() + ")");
  27.         slotMachines[1].setCurrentSpin(slotMachineInput.nextInt());
  28.         System.out.println("How many times has " + slotMachines[2].getName()
  29.                 + " played since last jackpot? (Maximum of "
  30.                 + slotMachines[2].getJackpotSpin() + ")");
  31.         slotMachines[2].setCurrentSpin(slotMachineInput.nextInt());
  32.  
  33.         while (margerie.getCoins() > 0) {
  34.             if (margerie.getCoins() > 0) {
  35.                 slotMachines[0].play(margerie);
  36.             }
  37.             if (margerie.getCoins() > 0) {
  38.                 slotMachines[1].play(margerie);
  39.             }
  40.             if (margerie.getCoins() > 0) {
  41.                 slotMachines[2].play(margerie);
  42.             }
  43.             // System.out.println(margerie);
  44.         }
  45.  
  46.         System.out.println(margerie.getName() + " played a total of "
  47.                 + SlotMachine.getTotalSpins() + " times.");
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement