I\'m trying to write a simple ball game, and there\'s several turns (ie., ball lives). The ball \"dies\" when it passes the bottom border of the screen. What I have so far w
The object can remove itself given it has some sort of reference to the view rendering mechanism. Your sample doesn't give enough information so I'll exemplify one way to do it:
public class Ball {
private ViewRenderer view;
public void remove() {
view.remove(this);
}
}
Neither suicide nor murder is better or worse. It depends on your design and requirements.
In this sample though, murder might be preferable since this way the Ball
object doesn't need to know in which context it's being used.