Viewport { public void move(int offsetX, int offsetY) { setPosition(getX() + offsetX, getY() + offsetY); } Viewport(double width, double height, World world); boolean isOnScreen(Drawable item); int getX(); int getY(); Point getPosition(); void setPosition(int newX, int newY); void move(int offsetX, int offsetY); int getWidthTiles(); int getMaxWidthTiles(); int getWidthPixels(); int getHeightTiles(); int getMaxHeightTiles(); int getHeightPixels(); void setWidthTiles(int newWidth); void setMaxWidthTiles(int newMaxWidth); void setHeightTiles(int newHeight); void setMaxHeightTiles(int newMaxHeight); void setSizeTiles(int width, int height); void setWidthPixels(double newWidth); void setHeightPixels(double newHeight); void setMaxWidthPixels(double newMaxWidth); void setMaxHeightPixels(double newMaxHeight);  }
@Test public void testMove() { Viewport viewport = new Viewport( 2 * TileRegister.TILE_SIZE, 2 * TileRegister.TILE_SIZE, world ); viewport.move(10, 10); assertEquals("Viewport position should be at (10,10)", new Point(10, 10), viewport.getPosition() ); viewport.move(-2, 3); assertEquals("Viewport position should be at (8,13)", new Point(8, 13), viewport.getPosition() ); viewport.move(4, -1); assertEquals("Viewport position should be at (12,12)", new Point(12, 12), viewport.getPosition() ); viewport.move(-5, -5); assertEquals("Viewport position should be at (7,7)", new Point(7, 7), viewport.getPosition() ); viewport.move(-8, -8); assertEquals("Viewport position should be at (0,0)", new Point(0, 0), viewport.getPosition() ); viewport.move(19, 0); assertEquals("Viewport position should be at (18,0)", new Point(18, 0), viewport.getPosition() ); viewport.move(0, 100); assertEquals("Viewport position should be at (18,18)", new Point(18, 18), viewport.getPosition() ); }