import java.awt.Panel; // *** public class BoundedBall extends MovableBall { private Panel myWorld; // *** public BoundedBall( int x, int y, int r, double dx, double dy, Panel aWorld ) // *** { super( x, y, r, dx, dy ); myWorld = aWorld; } public void move() { super.move(); int maxHeight = myWorld.getHeight(); int maxWidth = myWorld.getWidth(); if ( (x() < 0) || (x() > maxWidth) ) setMotion( -xMotion(), yMotion() ); if ( (y() < 0) || (y() > maxHeight) ) setMotion( xMotion(), -yMotion() ); } }