package reversi.model; import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JOptionPane; /** * Class for a Illegal move in reversi game. */ public class IllegalMoveException extends RuntimeException { private static final long serialVersionUID = 240330120795325167L; /** * Prints an error or plays a "beep" if a illegal move is made. * A beep is more common but not so easy to implement for various * OS, so the sound is only played on Windows XP or 7. * * @param s Error to print */ public IllegalMoveException(final String s) { if (System.getProperty("os.name").equals("Windows 7") || System.getProperty("os.name").equals("Windows XP")) { Toolkit.getDefaultToolkit().beep(); } else { JFrame screen = new JFrame(); JOptionPane.showMessageDialog(screen, s); } } }