Files
Prog_1/Reversi/reversi/model/IllegalMoveException.java
Felix Steghofer c3f4512037 fix java shit
2022-12-04 01:45:18 +01:00

31 lines
902 B
Java

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);
}
}
}