// // FILE: BoundedBall // AUTHOR: Eugene Wallingford // DATE: 2012/10/02 // COMMENT: a Ball that bounces off the sides of its Frame // implemented during Session 13 // // MODIFIED: // CHANGE: // import java.awt.Frame; public class BoundedBall extends Ball { private Frame myWorld; public BoundedBall( int x, int y, int r, int dx, int dy, Frame f ) { super( x, y, r, dx, dy ); myWorld = f; } public void move() { super.move(); int maxWidth = myWorld.getWidth(); if (( x() < 0 ) || ( x() > maxWidth )) reverseDeltaX(); int maxHeight = myWorld.getHeight(); if (( y() < 0 ) || ( y() > maxHeight )) reverseDeltaY(); } }