Intro Ex1 Ex2 Ex3 Ex4 Ex5

Invariants: Sanitize input

Task: Pass tests.PointBounds.

Instead of throwing an exception when one of the int fields of Point is set to a negative value, write an aspect to trim the value to zero.

Tools: around advice; note that inside the body of an around advice, you can invoke a proceed statement with (possibly different) join point parameters.

Your aspect is going to look like this:

public aspect Answer4 {
  void around(int val): <pointcut> {
    <if necessary, sanitize val>
    proceed(val);
  }
}

With a correct implementation, you should pass tests.PointBounds.


When done, remove your aspect from the build path and continue with Exercise 5.