Craps赌博游戏

public class CrapsGame {

	public static int roll() {
		return (int) (Math.random() * 6 + 1);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int money = 10000;
		int ante = 0;
		int firstPoint, currentPoint;

		boolean sequel = true;

		do {
			boolean goon = false;
			firstPoint = currentPoint = roll() + roll();
			System.out.print("你现在有" + money + "元,请下注:");
			ante = sc.nextInt();
			System.out.println("玩家摇出了: " + firstPoint + " 点");
			switch (firstPoint) {
			case 7:
			case 11:
				System.out.println("玩家胜!!!");
				money += ante;
				break;
			case 2:
			case 3:
			case 12:
				System.out.println("庄家胜!!!");
				money -= ante;
				break;
			default:
				goon = true;
				break;
			}
			while (goon) {
				currentPoint = roll() + roll();
				System.out.println("玩家摇出了: " + currentPoint + " 点");
				if (currentPoint == 7) {
					System.out.println("玩家输");
					money -= ante;
					goon = false;
				} else if (currentPoint == firstPoint) {
					System.out.println("玩家赢!!!");
					money += ante;
					goon = false;
				}
			}
			System.out.println("现在有" + money + "元");
			if (money <= 0) {
				System.out.println("你已经输完了,赌博结束!!!");
			} else {
				System.out.println("是否继续?1,继续  2,不继续");
			}
			int x = sc.nextInt();
			if (x == 1) {
				sequel = true;
			} else {
				sequel = false;
			}
		} while (sequel);

	}
}

  

posted @ 2014-10-20 19:05  SUPER-YueYue  阅读(226)  评论(0编辑  收藏  举报