Advertisement
Vermiculus

Untitled

Dec 5th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. public class Casino {
  2.     public static final PlayingCards.MersenneTwister MRAND = new PlayingCards.MersenneTwister();
  3.     public static double wallet = 1000;
  4.    
  5.     public static void play() {
  6.         System.out.println("Welcome to the Casino!");
  7.        
  8.         switch(menu()) {
  9.         case 1:
  10.             Baccarat.play();
  11.             break;
  12.         case 2:
  13.             (new Blackjack()).play();
  14.             break;
  15.         case 0:
  16.             System.out.print("See you next time!");
  17.         }
  18.     }
  19.    
  20.     public static int menu() {
  21.         System.out.println("What game would you like to play?");
  22.         System.out.println("1) Baccarat");
  23.         System.out.println("2) Blackjack");
  24.         System.out.println("0) Exit Casino");
  25.         return getInt(0, 2);
  26.     }
  27.    
  28.     public static int getInt(int min, int max) {
  29.         try {
  30.             int t = (new java.util.Scanner(System.in)).nextInt();
  31.             if(t < min || t > max) throw new Exception();
  32.             else return t;
  33.         } catch (Exception e) {
  34.             System.out.printf("Invalid. Please enter a number between %d and %d.%n", min, max);
  35.             return getInt(min, max);
  36.         }
  37.     }
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement