1 
2 import java.util.Scanner;
3 
4 import au.edu.mq.itec802.cardGame.blackjack.BlackjackGame;
5 
6 /**
7  * Class BlackjackClient
8  *
9  * Sample client program for the Blackjack game developed as Assignment 1
10  * for ITEC802@MQ
11  *
12  * @author		Tomas Krajca <tomas.krajca@students.mq.edu.au>
13  * @version 	$Id: BlackjackClient.java 22/03/2011 jumbo$
14  */
15 public class BlackjackClient {
16 	/**
17 	 * Main
18 	 *
19 	 * @param args
20 	 */
main(String[] args)21 	public static void main(String[] args) {
22 		Scanner in = new Scanner(System.in);
23 		int amount = 0;
24 		int bet = 0;
25 
26 		do {
27 			System.out.print("Please enter amount to begin with: ");
28 			do {
29 				try {
30 					amount = Integer.parseInt(in.nextLine());
31 					if (amount > 0)
32 						break;
33 				} catch (NumberFormatException e) {
34 				}
35 				System.out.print("Please enter a positive integer: ");
36 			} while (amount <= 0);
37 
38 			System.out.print("Please enter bet for each round: ");
39 			do {
40 				try {
41 					bet = Integer.parseInt(in.nextLine());
42 					if (bet > 0)
43 						break;
44 				} catch (NumberFormatException e) {
45 				}
46 				System.out.print("Please enter a positive integer: ");
47 			} while (bet <= 0);
48 
49 			if (amount >= bet)
50 				break;
51 			System.out
52 					.println("Please enter a correct amount and bet (you \ncannot bet more than you have)");
53 		} while (bet > amount);
54 
55 		BlackjackGame game = new BlackjackGame(2, new int[] { amount, amount },
56 				new int[] { bet, bet });
57 
58 		game.play();
59 
60 		System.out.println();
61 		System.out.println(game);
62 	}
63 }
64