abstract public class MobileSimObject extends SimObject {
	// OVERVIEW: A MobileSimObject is a simulator object that can move.
	//    Note: its still an abstract class since we didn't implement executeTurn.

	synchronized public void setLocation(int newx, int newy)
	// REQUIRES: The square in the grid at newrow, newcol is empty.
	//@requires isInitialized						      
	// MODIFIES: this
	// EFFECTS: sets this SimObject's location to newrow, newcol.
	{ //@nowarn Deadlock
		if (grid.getObjectAt(newx, newy) != null) { //@nowarn Pre
			throw new RuntimeException(
				"BUG: SimObject.setLocation - "
					+ newx
					+ ", "
					+ newy
					+ " already occupied.");
		}

		// Empty location, move to it.
		grid.removeObjectAt(mx, my); //@nowarn Pre

		try {
			grid.setObjectAt(newx, newy, this);
		} catch (BadLocationException e) {
			throw new RuntimeException(
				"BUG: SimObject.setLocation - bad location: "
					+ newx
					+ ", "
					+ newy);
		}
		mx = newx;
		my = newy;
	} //@nowarn Exception // Don't warn about the unexpected Runtime exception.
}