投掷骰子游戏
来源:互联网 发布:网络电话软件隐藏号码 编辑:程序博客网 时间:2024/05/02 03:02
package pritice4;
public class SieveGame {
public static void main(String[] args) {
// 置筛子游戏,两个筛子,如果两个筛子的和为2,3,12,你输了,如果为7,11,你赢了,如果为其他数,
//就确定了一个点,继续置筛子,直到置到7或者相同的数,如果置到7则你输了,相同你赢了
int frist = ((int)(Math.random()*6))+1;
int second = ((int)(Math.random()*6))+1;
int sum = frist + second;
//int point = sum;
if((sum==2)||(sum==3)||(sum==12))
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("you lose!");
}
else if((sum==7)||(sum==11))
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("you win!");
}
else if((sum==4)||(sum==5)||(sum==6)||(sum==8)||(sum==9)||(sum==10))
{
int point = sum;
int three1 = ((int)(Math.random()*6))+1;
int three2 = ((int)(Math.random()*6))+1;
if((three1+three2) == 7)
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("point is "+sum);
System.out.println("you rolled "+three1+" + "+three2+" = "+(three1+three2));
System.out.println("you lose!");
}
else if((three1+three2) == point)
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("point is "+sum);
System.out.println("you rolled "+three1+" + "+three2+" = "+(three1+three2));
System.out.println("you win!");
}
}
}
}
public class SieveGame {
public static void main(String[] args) {
// 置筛子游戏,两个筛子,如果两个筛子的和为2,3,12,你输了,如果为7,11,你赢了,如果为其他数,
//就确定了一个点,继续置筛子,直到置到7或者相同的数,如果置到7则你输了,相同你赢了
int frist = ((int)(Math.random()*6))+1;
int second = ((int)(Math.random()*6))+1;
int sum = frist + second;
//int point = sum;
if((sum==2)||(sum==3)||(sum==12))
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("you lose!");
}
else if((sum==7)||(sum==11))
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("you win!");
}
else if((sum==4)||(sum==5)||(sum==6)||(sum==8)||(sum==9)||(sum==10))
{
int point = sum;
int three1 = ((int)(Math.random()*6))+1;
int three2 = ((int)(Math.random()*6))+1;
if((three1+three2) == 7)
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("point is "+sum);
System.out.println("you rolled "+three1+" + "+three2+" = "+(three1+three2));
System.out.println("you lose!");
}
else if((three1+three2) == point)
{
System.out.println("you rolled "+frist+" + "+second+" = "+sum);
System.out.println("point is "+sum);
System.out.println("you rolled "+three1+" + "+three2+" = "+(three1+three2));
System.out.println("you win!");
}
}
}
}
0 0
- 投掷骰子游戏
- 投掷骰子
- c现代编程 模拟投掷骰子的游戏
- 重学C++ switch 投掷骰子
- 骰子游戏
- n个m面骰子,投掷100次结果统计
- 每隔五秒执行一次 共十次 模拟骰子的投掷
- 模拟投掷骰子,一至六点出现的次数…
- 第一个骰子游戏
- 骰子游戏问题
- js骰子游戏
- html5 骰子游戏
- 掷骰子游戏
- c++投骰子游戏
- JAVA 骰子游戏
- Android骰子游戏案例
- 掷骰子游戏
- 掷骰子游戏
- php格式化函数
- C语言解析XML文档 用libxml库
- getComputedStyle && currentStyle
- HTTP深入浅出 http请求
- 播放音频SoundHelper
- 投掷骰子游戏
- CocoaPods的安装及使用
- 软件的设计理念
- java向上转型方法调用的问题
- 程序员写作必备-Word2010从正文开始设置页码
- oracle下dbca不能使用
- AndroidStudio Shortcut
- 人脸识别算法嵌入式移植的一点经验
- BZOJ2527【整体二分】