HexPosition { public boolean isAtModel(final HexEngineModel<?> model){ final int col = getColumn(); final int row = getRow(); return col>=0 && col<model.getColumnNumber() && row>=0 && row<model.getRowNumber(); } HexPosition(final int column, final int row); int getColumn(); int getRow(); boolean isAtModel(final HexEngineModel<?> model); @Override int hashCode(); @Override boolean equals(final Object object); int calcDistance(final HexPosition pos); int calcDistance(final int col, final int row); static int calcDistance(final int col1, final int row1, final int col2, final int row2); static int calcDistance(final HexPosition pos1, final HexPosition pos2); @Override String toString();  }
@Test public void testIsAtModel(){ final HexEngineModel<Integer> model = new DefaultIntegerHexModel(32, 16, -1); assertTrue(new HexPosition(0, 0).isAtModel(model)); assertTrue(new HexPosition(31, 15).isAtModel(model)); assertFalse(new HexPosition(-1, 0).isAtModel(model)); assertFalse(new HexPosition(0, -1).isAtModel(model)); assertFalse(new HexPosition(32, 16).isAtModel(model)); assertFalse(new HexPosition(32, 15).isAtModel(model)); assertFalse(new HexPosition(31, 16).isAtModel(model)); }