/**
* 赌博游戏
*/
package com.lovo;
public class Test05 {
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 (currentpoint == firstpoint) {
System.out.println("玩家胜利!!!");
goon = false;
}
}
}
}