Newer
Older
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI.game;
public Model model;
public Game game;
public StopWatch watch;
private Boolean isStopButtonPressed;
this.isStopButtonPressed = false;
public void stopButtonPressed()
{
this.isStopButtonPressed = true;
}
public void registerView(View view)
{
this.view = view;
}
public void registerModel(Model model)
public void registerGame(Game game)
{
this.game = game;
}
public int getButtonState()
{
if( isStopButtonPressed )
return 1;
return -1;
}
public void resetButtonState()
{
this.isStopButtonPressed = false;
private int[] getButtonPos(String buttonName)
{
String[] splitted = buttonName.split(":");
int[] pos = new int[2];
pos[0] = Integer.parseInt(splitted[0]);
pos[1] = Integer.parseInt(splitted[1]);
return pos;
}
{
int[]pos = this.getButtonPos(button);
public void gameRightButtonPressed(String button)
{
int[] pos = this.getButtonPos(button);
model.flagButton(pos);
}
public void gameStart()
{
if( this.model != null && this.view != null )
{
watch = new StopWatch(this);
watch.startTimer();
public void gameOver()
{
this.model.isGameOver = true;
this.watch.stopTimer();
}
public void newGame()
this.game.newGame();