import java.util.Random;
/**
* 模拟扔硬币
* @author Administrator
*
*/
public class Coins
{
int c;
int throwCoins() {
Random rand = new Random();
c = rand.nextInt(2);
return c;
}
String getResult(int c) {
String str = "";
switch(c) {
case 1:
str = "正面";
break;
case 0:
str = "反面";
break;
}
return str;
}
public static void main(String[] args) {
Coins cn = new Coins();
System.out.println(cn.getResult( cn.throwCoins() ));
}
}
模拟扔硬币
最新推荐文章于 2023-03-09 23:03:39 发布