package s3;
import javax.swing.*;
public class Guessnumber{
public static void main(String args[]) {
exam2();
}
public static void exam2() {
int a=(int)(Math.random()*100)+1;
while(true) {
String c=JOptionPane.showInputDialog("请输入一个1到100之间的数字");
int c1=Integer.parseInt(c);
if(c1>a) {
JOptionPane.showMessageDialog(null,"数字大了");
continue;
}
else if(c1<a) {
JOptionPane.showMessageDialog(null,"数字小了");
continue;
}
else if(c1==a){
JOptionPane.showMessageDialog(null,"答对啦!");
int response= JOptionPane.showConfirmDialog(null,"是否再来一轮","游戏选择",JOptionPane.YES_NO_OPTION);
if(response!=JOptionPane.NO_OPTION) {
exam2();
}
else break;
}
break;
}
}
}