我在父类中有三个变量可以改变游戏的难度。
public class MineSweeper implements ActionListener{
int gridlength = 20;
int gridheight = 20;
int numMines = 30;
当用户点击新游戏时,会出现一个提示,允许用户更改难度。它确实运行以下提示,但它始终恢复为上面的值。如何更改新游戏的值?
public void actionPerformed(ActionEvent e) {
if (e.getSource() == newGame){
String gridl = JOptionPane.showInputDialog(subframe, "Please enter in the amount of columns.");
gridlength = Integer.parseInt(gridl);
String gridh = JOptionPane.showInputDialog(subframe, "Please enter in the amount of rows.");
gridheight = Integer.parseInt(gridh);
String amountOfMines = JOptionPane.showInputDialog(subframe, "Please enter in the amount of mines.");
numMines = Integer.parseInt(amountOfMines);
new MineSweeper();