谁会用JAVA编写程序随机产生20—50根火柴
来源:百度知道 编辑:UC知道 时间:2024/05/27 14:05:40
由人与计算机轮流拿,每次拿的数量不超过3根,拿到最后一根为胜。
DOS界面就行!
DOS界面就行!
import java.util.Random;
import java.io.*;
public class MatchGame {
private Random rnd = new Random ();
private int total;
private boolean yourTurn;
private boolean youWin;
public MatchGame () {
this.total = this.rnd.nextInt(15) + 20;
}
public MatchGame (boolean youFirst) {
this();
this.yourTurn = yourTurn;
}
public void takeAway (boolean yourTurn) {
&nbs