class MineController { MineModel mm; MineGuiInterface mtg; boolean isRunning = false; MineController() { isRunning = true; // Her kan man bytte mellom å enten spille i terminal eller med GUI // mtg = new MineTerminalGui(this); mtg = new MineSwingGui(this); } public void start() { mtg.start(); } public String getSquareText(int row, int col) { if (!checkCoords(row, col)) return " "; return mm.grid.grid[row][col].toString(); } public boolean isMine(int row, int col) { if (!checkCoords(row, col)) return false; return mm.grid.grid[row][col].isMine; } public void setStatus(int row, int col, int status) { if (!checkCoords(row, col)) return; mm.grid.grid[row][col].status = status; } public boolean checkCoords(int row, int col) { return mm.checkCoords(row, col); } public void createModel(int rows, int cols, int numMines) { mm = new MineModel(rows, cols, numMines); } public void showGame() { System.out.println(mm); } public void toggleSquare(int row, int col) { mm.toggleSquare(row, col); } public void openSquare(int row, int col) { if (mm.openSquare(row, col)) { mtg.hasWon(false); isRunning = false; } else if (mm.checkIfWon()) { mtg.hasWon(true); isRunning = false; } } }