【菜鸟请教】//[如下代码中,为何‘石’、‘剪’可以,而‘石头’、‘剪刀’不可以??,菜鸟,所以解释的的越简单越好]
public class Test02{
public static void main(String args []){
char play1 = '石';
char play2 = '剪';
if(play1 == '石' && play2 == '石'){
System.out.println("平");
}
else if(play1 == '石' && play2 == '剪'){
System.out.println("玩家一赢");
}
else if(play1 == '石' && play2 == '布'){
System.out.println("玩家二赢");
}
else if(play1 == '剪' && play2 == '石'){
System.out.println("玩家二赢");
}
else if(play1 == '剪' && play2 == '剪'){
System.out.println("平");
}
else if(play1 == '剪' && play2 == '布'){
System.out.println("玩家一赢");
}
else if(play1 == '布' && play2 == '石'){
System.out.println("玩家一赢");
}
else if(play1 == '布' && play2 == '剪'){
System.out.println("玩家二赢");
}
else if(play1 == '布' && play2 == '布'){
System.out.println("平");
}
}
}
public static void main(String args []){
char play1 = '石';
char play2 = '剪';
if(play1 == '石' && play2 == '石'){
System.out.println("平");
}
else if(play1 == '石' && play2 == '剪'){
System.out.println("玩家一赢");
}
else if(play1 == '石' && play2 == '布'){
System.out.println("玩家二赢");
}
else if(play1 == '剪' && play2 == '石'){
System.out.println("玩家二赢");
}
else if(play1 == '剪' && play2 == '剪'){
System.out.println("平");
}
else if(play1 == '剪' && play2 == '布'){
System.out.println("玩家一赢");
}
else if(play1 == '布' && play2 == '石'){
System.out.println("玩家一赢");
}
else if(play1 == '布' && play2 == '剪'){
System.out.println("玩家二赢");
}
else if(play1 == '布' && play2 == '布'){
System.out.println("平");
}
}
}
...全文
相关推荐
一个自己写的剪刀石头布小游戏
一个自己写的小游戏,玩剪刀石头布,需要源代码的话,请联系我我的邮箱是yinzelin0420@126.com.有什么意见和建议的话也请发邮件给我。本人是菜鸟。多多交流一下。
VISUAL STUDIO2008自制手机游戏
首先,让我们了解"石头剪子布"游戏的开发过程。这是一个基于用户交互的简单游戏,通常涉及两个玩家选择石头、剪刀或布,然后根据规则(石头砸剪刀,剪刀剪布,布包石头)决定胜负。
20行python代码的入门级小游戏的详解
"这篇教程介绍了如何使用Python编写一个简单的数字猜谜游戏,旨在帮助初学者通过实践学习Python编程。"本文将深入解析标题为“20行Python代码的入门级小游戏”的内容,这是一个数字猜谜
广东屈臣氏饮料制造项目-全专业-20240508.nwd
广东屈臣氏饮料制造项目_全专业-20240508.nwd
Python3 if多条件简写技巧
Python3支持极简if条件写法,简化冗余代码。链式比较:原生支持1<x<10,无需写成x>1 and x<10,可读性更强。三元表达式:适用于二分支逻辑,语法 结果A if 条件 else 结果B,适合单行赋值,禁止多层嵌套三元表达式,会大幅降低可读性。逻辑短路:and左侧为False直接终止判断,or左侧为True直接终止判断,可用于空值兜底,比如name = input_name or "匿名用户"。注意不要混用=和==,新手常误将赋值写在if判断内,Python3会直接抛出语法异常。 6thhosp-east.com 3wfuwu.com ajfcw.net www.ahdmhbkj.cn www.aiyouseo.com


