RectangularBox { public void rotate(Rotation desiredRotation) { if (desiredRotation != null) { Rotation currentRotation = Rotation.DEGREES_0; while (!currentRotation.equals(desiredRotation)) { switchTopRight(); switchBottomLeft(); currentRotation = currentRotation.rotateClockwise(); } } } RectangularBox(int bottom, int left, int top, int right); int getBottom(); int getLeft(); int getTop(); int getRight(); void rotate(Rotation desiredRotation); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object other); static RectangularBox newInstance(int bottom, int left, int top, int right); static RectangularBox newInstanceFromPoints(Point bottomLeft, Point topRight); TopLeftRectangularBox toTopLeftRectangularBox();  }
@Test public void testRotate() { RectangularBox victim = RectangularBox.newInstance(0, 1, 10, 9); victim.rotate(Rotation.DEGREES_270); assertEquals(1, victim.getBottom()); assertEquals(0, victim.getLeft()); assertEquals(9, victim.getTop()); assertEquals(10, victim.getRight()); }