Below is the syntax highlighted version of Ball.java.
/************************************************************* * Compilation: javac Ball.java * Execution: java Ball * Dependencies: StdDraw.java * * Object oriented implementation of a 2-d Ball, Booksite 3.4 *************************************************************/ public class Ball { // declare instance variables _____________________________________________ // position _____________________________________________ // velocity _____________________________________________ // radius // constructor public Ball() { // Always start ball position at (0, 0) // Initial velocity and size generated randomly } // move the ball one step public void move() { // Bounce off border walls // update position using unit change in time } // draw the ball public void draw() { } // test client: This part is complete. public static void main(String[] args) { // create and initialize two balls Ball b1 = new Ball(); Ball b2 = new Ball(); // animate them StdDraw.setXscale(-1.0, +1.0); StdDraw.setYscale(-1.0, +1.0); while (true) { StdDraw.setPenColor(StdDraw.GRAY); StdDraw.filledSquare(0.0, 0.0, 1.0); StdDraw.setPenColor(StdDraw.BLACK); b1.move(); b2.move(); b1.draw(); b2.draw(); StdDraw.show(20); } } }