This is an old revision of the document!
Table of Contents
Invariants: Postconditions
Point Move Postcondition
Task: Pass tests.PointMovePostcondition.
A postcondition of the move operation of a Point is that the coordinates should change accordingly. If a call to move didn't actually move a point by the desired offset, then the point is in an illegal state and so an IllegalStateException should be thrown.
around advice. Note that because we're dealing with how the coordinates change during move, we need access to the coordinates both before and after the move, in one piece of advice.
When the access to the old coordinates and move arguments has been established, the check comes down to essentially the following code:
if(p.getX() - oldx != dx || p.getY() - oldy != dy) throw new IllegalStateException();
With a correct implementation, you should pass the tests of suite tests.PointMovePostcondition.
Bounds Move Postcondition
Task: Pass tests.BoundsMovePostcondition.
FigureElement objects have a getBounds() method that returns a java.awt.Rectangle representing the bounds of the object. An important postcondition of the general move operation on a figure element is that the figure element's bounds rectangle should move by the same amount as the figure itself. Write an aspect to check for this postcondition – throw an IllegalStateException if it is violated.
Rectangle API:
- Employ the copy constructor to create a clone of the original bounds.
 - Replay the move on the clone with the
translatemethod. - Compare the result to the actual new bounds using the
equalsmethod. 
A correct implementation should pass the tests of suite tests.BoundsMovePostcondition.
When done, remove the aspect from the build path and continue with 
