📄 guessinggame.txt
字号:
// Program to allow the user to play a guess the number game
import javax.swing.JOptionPane;
public class GuessingGame
{
public static void guessyguessy()
{
final int SECRETNUMBER = 75;
String str = JOptionPane.showInputDialog(
"Guess the number?");
int guess = Integer.parseInt(str);
while (guess != SECRETNUMBER)
{
if (guess > SECRETNUMBER)
JOptionPane.showMessageDialog(null,"Too high!");
else // guess must be too low
JOptionPane.showMessageDialog(null,"Too low!");
str = JOptionPane.showInputDialog(null,"Try again");
guess = Integer.parseInt(str);
}
JOptionPane.showMessageDialog(null, "Correct!");
}
public static void main(String[] args)
{
guessyguessy();
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -