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; } } } }
两个

浙公网安备 33010602011771号