From 0d80b0e37c2e00da40783cd8d49012233ed187ea Mon Sep 17 00:00:00 2001 From: lov3b Date: Sun, 15 May 2022 22:21:01 +0200 Subject: [PATCH] Bort med logger + fallthrough --- src/schack/Board.java | 15 +++++---------- src/schack/Schack.java | 2 -- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/schack/Board.java b/src/schack/Board.java index 709e9e4..0384e13 100644 --- a/src/schack/Board.java +++ b/src/schack/Board.java @@ -122,20 +122,15 @@ public class Board extends JPanel implements MouseListener { JOptionPane.showMessageDialog(this, "Du står i schack"); break; case SCHACKMATT: - if (JOptionPane.showConfirmDialog(this, "Schackmatt\nVill du starta om?") == JOptionPane.YES_OPTION) { - try { - restartGame(); - } catch (IOException ex) { - Logger.getLogger(Board.class.getName()).log(Level.SEVERE, null, ex); - } - } - break; case PATT: - if (JOptionPane.showConfirmDialog(this, "Patt\nVill du starta om?") == JOptionPane.YES_OPTION) { + String stateStr = state.toString(); + String msg = stateStr.charAt(0) + stateStr.substring(1, stateStr.length()).toLowerCase(); + int choice = JOptionPane.showConfirmDialog(this, msg + "\nVill du starta om?"); + + if (choice == JOptionPane.YES_OPTION) { try { restartGame(); } catch (IOException ex) { - Logger.getLogger(Board.class.getName()).log(Level.SEVERE, null, ex); } } break; diff --git a/src/schack/Schack.java b/src/schack/Schack.java index b2f980b..86c9be5 100644 --- a/src/schack/Schack.java +++ b/src/schack/Schack.java @@ -76,7 +76,6 @@ public class Schack { try { board.restartGame(); } catch (IOException ex) { - Logger.getLogger(Schack.class.getName()).log(Level.SEVERE, null, ex); } } } @@ -88,7 +87,6 @@ public class Schack { try { board.restartGame(); } catch (IOException ex) { - Logger.getLogger(Schack.class.getName()).log(Level.SEVERE, null, ex); } } });