Namdrib / java-minesweeper

A Java version of Mineseweeper.
MIT License
0 stars 0 forks source link

bad custom fields should default to beginner values #20

Closed Namdrib closed 4 years ago

Namdrib commented 5 years ago

in Minesweeper.rbMenuItem.addActionListener, entering a bad input for heightField, widthField or minesField (e.g. empty strings, non-numerical input, etc.) should result in beginner values for each incorrect field.

2018-12-01_18-31-29

          try {
            newHeight = Integer.parseInt(heightField.getText());
          } catch (NumberFormatException ex) {
            newHeight = 9;
          }
          try {
            newWidth = Integer.parseInt(widthField.getText());
          } catch (NumberFormatException ex) {
            newWidth = 9;
          }
          try {
            newMines = Integer.parseInt(minesField.getText());
          } catch (NumberFormatException ex) {
            newMines = 10;
          }

This requires an individual try/catch since each field is treated individually

Namdrib commented 5 years ago

Current behaviour is to just abort changing the difficulty

Namdrib commented 4 years ago

Fixed by 9db1c0f