Java 两个骰子的 赌博游戏

 package com.love;
/**
 * Craps赌博游戏
 * 
 *
 */

public class Test08 {
    public static int roll(){
        return (int) (Math.random() * 6 + 1);
    }
    public static void main(String[] args) {
        int firstPoint, currentPoint;
        firstPoint = currentPoint = roll() + roll();
        System.out.println("玩家摇出了" + currentPoint + "点");
        boolean goon = false;
        switch (currentPoint){
        case 7:
        case 11:
            System.out.println("玩家胜!!!");
            break;
        case 2:
        case 3:
        case 12:
            System.out.println("庄家胜!!!");
            break;
        default :
            goon = true;        
        }
        while (goon){
            currentPoint = roll() + roll();
            System.out.println("玩家掷出了" + currentPoint + "点");
            if (currentPoint == 7){
                System.out.println("庄家胜");
                goon = false;
            }
            else if (firstPoint == currentPoint){
                System.out.println("玩家胜");
                break;
            }
        }
        
        
    }

}

两个

posted @ 2014-10-17 19:26  魔尊-luy  阅读(626)  评论(0)    收藏  举报