Ball
interface. Once this class is compiled it can be loaded into the program. For
Each loaded Ball class the program will create a button. clicking the button
creates a new instance of the ball in the ballworld, which will regular
query the location and radius of the ball and redraw it accordingly. The ball
world also sends mouse clicks to the ball containing the clicked point (if any), and
sends keys typed to the currently selected ball.
There are many ways to run the code in class. You should choose the one that your students are ready for. They are presented in an order that represents an increasing usage of the command line utilities and options.
1.)a) Click here b) File > Expand Classpath > (choose jar/dir of package of student code.) c) File > Load Ball > (enter fully qualified Class name for student code) (requires Java WebStart). If you want to put a link on your course web site, you may use a link like this (subject to our terms of use like all materials on the site): <a href="http://www.cs101.org/psets/ballworld/demo/ballworld.jnlp">Click Here</a> 2. a) java -jar ballworld.jar b) File > Expand Classpath > (choose jar/dir of package of student code.) c) File > Load Ball > (enter fully qualified Class name for student code) 3. a) java -cp ballworld.jar ballworld.Main b) File > Expand Classpath > (choose jar/dir of package of student code.) c) File > Load Ball > (enter fully qualified Class name for student code) 4. a) java -cp "ballworld.jar:/path/to/student/code" ballworld.Main b) File > Load Ball > (enter fully qualified Class name for student code) 5. a) java -cp "ballworld.jar:/path/to/student/code" ballworld.Main stupkg.StudentBall [stupkg.StudentBall2] 6. a) jar -xvf ballworld.jar b) java ballworld.Main c) File > Expand Classpath > (choose jar/dir of package of student code.) d) File > Load Ball > (enter fully qualified Class name for student code) 7 thru 9 same permutations on the unpacked executable jar. 10 - 13 again but start with the source jar, add compilation step(s). (Line 6b assumes that you have the current directory on your default class path)
This image show the ball world with two Throbber balls (which change radius in and out) and an exploder ball which has explodded into a couple dozen balls. The upper left throbber is the currently selected ball so it is rendered in red.
This image is a second screen shot from the same run of the program. A new type of ball has been loaded (Faller) and five of them have been added to the Ball World. The exploder shown is not the same exploder, since exploders disintigrate rather quickly. The last Faller added is the currently selected ball.