public Object result(Object s, Action a)
{
if (a is QueenAction)
{
QueenAction qa = (QueenAction)a;
NQueensBoard board = (NQueensBoard)s;
NQueensBoard newBoard = new NQueensBoard(board.getSize());
newBoard.setBoard(board.getQueenPositions());
if (qa.getName() == QueenAction.PLACE_QUEEN)
newBoard.AddQueenAt(qa.getLocation());
else if (qa.getName() == QueenAction.REMOVE_QUEEN)
newBoard.removeQueenFrom(qa.getLocation());
else if (qa.getName() == QueenAction.MOVE_QUEEN)
newBoard.moveQueenTo(qa.getLocation());
s = newBoard;
}
// if action is not understood or is a NoOp
// the result will be the current state.
return s;
}
}