I have the unit test below:
public void testPawnOnMove()
{
thepawn = new Pawn(true, 0, 0, 0);
thespot.placePiece(thepawn);
thepawn.setMC(4);
Spot cantgo = new Spot(0,2,0);
thepawn.OnMove(thepawn, thespot, thespot); //moves piece to same location
thepawn.OnMove(thepawn, thespot, cantgo);
Assert.assertFalse(cantgo.isOccupied());
Spot cango = new Spot(0,1,0);
thepawn.OnMove(thepawn,thespot,cango);
Assert.assertTrue(cango.isOccupied());
}
but when it gets to the line thepawn.OnMove(thepawn, thespot, cango); and I step into the logic it says it cannot find local variable theMove, even though it is declared right above it. It also can't find the 3 parameters passed to it. The OnMove method is below :
public void OnMove(Pawn pawn, Spot source, Spot destination)
{
if (source == destination)
{
//exit selected mode
return;
}
Mover theMove = new Mover();
try
{
if (theMove.TryMove(pawn, source, destination)) {
pawn.setMC(pawn.getMC() + 1);
if (destination.isOccupied()) {
destination.releaseSpot();
destination.placePiece(pawn);
} else {
destination.placePiece(pawn);
}
//update view.
} else { } } //end if block //end try block //return to selected mode TODO fill else block with return to selected mode
catch (NullPointerException objectmissing)
{ }
}
Aucun commentaire:
Enregistrer un commentaire