Problem written by Chris.
Makes a ball that bounces as if under the influence of gravity.
public class GravityBall extends GraphicsProgram {private static final int SIZE = 20;private static final int DELAY = 20;private static final double GRAVITY = 0.5;private static final double DAMPING = 0.7;public void run() {// Draw a ball on the top right cornerGOval oval = new GOval(0,0,SIZE, SIZE);oval.setFilled(true);add(oval);// Declare variables for velocitydouble vx = 3;double vy = 0;while(true) {// update vyvy = vy + GRAVITY;// should the ball bounce?if(oval.getY() > (getHeight() - SIZE) && vy > 0) {vy = vy * -DAMPING;}// moveoval.move(vx, vy);// animation pause.pause(DELAY);}}}