[size=large][/size][color=red][/color][align=center][/align]package com.lovo;
import javax.swing.JOptionPane;
/**
*
* @author WenCHuan 猜數字遊戲
*/
public class NumGame {
/**
* @param args
*/
public static void main(String[] args) {
int number1 = (int) (100 * Math.random() + 10);
System.out.println(number1);
outter: for (int i = 1; i < 20; i++) {
String Num = JOptionPane.showInputDialog("请输入一个10--100之间的数:");
int number = Integer.parseInt(Num);
if (i < 2 && number == number1) {
JOptionPane.showMessageDialog(null, "哇!你真厉害!!");
} else if (number > number1) {
JOptionPane.showMessageDialog(null, "大了、、");
} else if (number < number1) {
JOptionPane.showMessageDialog(null, "小了、、");
} else if (i <= 6 && number == number1) {
JOptionPane.showMessageDialog(null, "中了!!下次的加油哦!");
} else if (i > 6 && number == number1) {
JOptionPane.showMessageDialog(null, "你猪啊!猜这么久!!");
} else {
JOptionPane.showMessageDialog(null, "猪!没有对、继续");
}
String b = JOptionPane.showInputDialog("是否还继续(y/n)");
while (b.equals("y")) {
continue outter;
}
while (b.equals("n")) {
break outter;
}
}
}
}
import javax.swing.JOptionPane;
/**
*
* @author WenCHuan 猜數字遊戲
*/
public class NumGame {
/**
* @param args
*/
public static void main(String[] args) {
int number1 = (int) (100 * Math.random() + 10);
System.out.println(number1);
outter: for (int i = 1; i < 20; i++) {
String Num = JOptionPane.showInputDialog("请输入一个10--100之间的数:");
int number = Integer.parseInt(Num);
if (i < 2 && number == number1) {
JOptionPane.showMessageDialog(null, "哇!你真厉害!!");
} else if (number > number1) {
JOptionPane.showMessageDialog(null, "大了、、");
} else if (number < number1) {
JOptionPane.showMessageDialog(null, "小了、、");
} else if (i <= 6 && number == number1) {
JOptionPane.showMessageDialog(null, "中了!!下次的加油哦!");
} else if (i > 6 && number == number1) {
JOptionPane.showMessageDialog(null, "你猪啊!猜这么久!!");
} else {
JOptionPane.showMessageDialog(null, "猪!没有对、继续");
}
String b = JOptionPane.showInputDialog("是否还继续(y/n)");
while (b.equals("y")) {
continue outter;
}
while (b.equals("n")) {
break outter;
}
}
}
}