Class PuzzleController

java.lang.Object
  extended byPuzzleController

public class PuzzleController
extends java.lang.Object


Constructor Summary
PuzzleController()
          Create Controller not bound to any model --- will cause null pointer exceptions if setModel(m) is not called before any Controller methods are called.
PuzzleController(PuzzleModel model)
          Create a controller for the designated model.
 
Method Summary
 void addView(PuzzleView view)
          Add a view to be updated by this controller when the model changes.
 int getModelSize()
          Returns the size of the model bound to this controller
 void makeMove(PuzzleMove move)
          Make a move (presumably results in changes to views)
 void setModel(PuzzleModel m)
          Set the model for this controller
 void showBoard(int[] list)
          Update view with new "board", called by model
 void undoMove()
          Undo the last undoable move (just made or uncovered as a result of an undo).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PuzzleController

public PuzzleController()
Create Controller not bound to any model --- will cause null pointer exceptions if setModel(m) is not called before any Controller methods are called.

See Also:
PuzzleController(PuzzleModel)

PuzzleController

public PuzzleController(PuzzleModel model)
Create a controller for the designated model. Multiple views can be added to a controller, but a control has a single model.

Parameters:
model - is the model for this controller
Method Detail

setModel

public void setModel(PuzzleModel m)
Set the model for this controller


addView

public void addView(PuzzleView view)
Add a view to be updated by this controller when the model changes.

Parameters:
view - is the view added to this controller

getModelSize

public int getModelSize()
Returns the size of the model bound to this controller

Returns:
the size of the model used by this controller

makeMove

public void makeMove(PuzzleMove move)
Make a move (presumably results in changes to views)

Parameters:
move - is the move made

undoMove

public void undoMove()
Undo the last undoable move (just made or uncovered as a result of an undo).


showBoard

public void showBoard(int[] list)
Update view with new "board", called by model

Parameters:
list - is the board, # elements in list is getModelSize()*getModelSize().