📄 gamelistener.java
字号:
package cs111.tetris.data;/** * This interface can be implemented by anyone who wants * to be notified when the state of a Game instance changes. * <p> * The Game class provides an <code>addListener()</code> method * to add listeners to a Game. * <p> * Typicaly a UI component implements the GameListener interface and calls * addListener to ask a Game to be notified of changes in the game * state. Thus, the GUI will know when it is necessary to update the * visual display of the game state on the screen. * <p> * <b>CS111 info:</b> Using this kind of Listener notification mechanism * is very typical for programs with a GUI. For example, you will find many different * listener interfaces also in the Java libraries. * <p> * This programming style allows us to decouple the game playing * logic and interesting data structures from the * GUI code. And so... this allows us to provide you with all * of that messy GUI related code and leave the more interesting * stuff to you! * * @author kdvolder */public interface GameListener { /** * This method is called by the game instance when the board state * changed (so the UI should redraw the board on the screen). */ public void boardChanged(); /** * This is called when the pieceCount was updated (e.g. a * new piece was entered at the top of the board). */ public void countChanged(); /** * This is called when the "gameOn" status changed. That * is, the game is either started or stopped. */ public void gameOnChanged();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -