我正在练习MVC风格的编程.我在一个文件中有一个Mastermind游戏,工作正常(可能除了"Check"按钮在开始时不可见).
http://paste.pocoo.org/show/226726/
但是当我把它重写为模型,视图,控制器文件时 - 当我点击空Pin(应该更新,并重新绘制新颜色)时 - 注意到了.谁能在这里看到任何问题?我尝试在不同的地方放置repaint(),但它根本不起作用:/
主要:
public class Main {
public static void main(String[] args){
Model model = new Model();
View view = new View("Mastermind", 400, 590, model);
Controller controller = new Controller(model, view);
view.setVisible(true);
}
}
Run Code Online (Sandbox Code Playgroud)
型号:
import java.util.Random;
public class Model{
static final int
LINE = 5,
SCORE = 10, OPTIONS = 20;
Pin pins[][] = new Pin[21][LINE];
int combination[] = new int[LINE];
int curPin = 0;
int turn = 1;
Random generator = new Random(); …Run Code Online (Sandbox Code Playgroud)