我正在尝试创建角色 2 骰子的程序。然后用户说“是”以再次角色骰子或说“否”以停止掷骰子。
import java.util.*;
public class Dice
{
public static void main(String[] args)
{
Random dice1 = new Random();
Scanner in = new Scanner(System.in);
//varibles
int die1;
int die2;
byte playagain=1;
byte Yes = 1;
byte No = 0;
int total;
int stop = 0;
//Want find I way to change words into #s
String start = Yes;
while(stop<5 && start<Yes){
stop+=1;
die1=dice1.nextInt(6)+1;
die2=dice1.nextInt(6)+1;
total=die1 + die2;
System. out. println("You rolled a " + total+ ".");
System. out. println("Do you want to play again?");
System. out. println("Type Yes to keep playing you and No to stop.");
/*I want people to be able to input Yes and that equal a # so I can use it in the While loop. Same with No.*/
start=in.next();
System. out. println("start is at " + start);
}
}
}
我浏览了整个互联网,找不到任何帮助,所以这就是我要问的原因。