Would someone be able to explain the meaning of what is going on in isOk the inner anonymous class? I understand the instance of comparison, but I don't understand the
"BlackHole.this.encloses".
BlackHole inherits an
encloses(...)
method, fyi.
Does this mean to use BlackHole's "this" instead of the anonymous class' "this"?
public class BlackHole extends Simulton {
private int radius = 10;
private ColoredCircle image;
private RemoveBehavior remove;
...
...
private final class implements Decision {
public boolean isOK(Object o) {
return o instanceof Prey && BlackHole.this.encloses(((Simulton)o).getLocation());
}
}
}
From the comments: There's also this in the constructor:
this.remove = new RemoveBehavior(new BlackHole.());
Does "BlackHole.()" imply calling the constructor of the anonymous inner class? (RemoveBehavior expects a Decision). I've never seen ".()" before.