BallWorlds specification -- Classes, Objects and Interfaces

Together, we will develop an application called BallWorlds that simulates "worlds" that contain various kinds of "balls".

When you run BallWorlds, a window appears like the one to the right. The window contains several "Worlds" -- the picture to the right has 3 Worlds. Each World has two parts:

  • a greenish area (WorldPanel) containing the World's Balls
  • a set of "BallButtons"
Each of the BallButtons represents a Java class -- a type of Ball -- that you will write.

Remember that Java classes are like recipes for creating objects. When you click on one of the BallButtons, the BallButton uses the class (recipe) to construct an object that is a new instance of the class, and a new ball will appear in the corresponding WorldPanel.

How the ball behaves will depend on the class that is used to create it. By defining several different classes, you will be able to create balls of several different types. Each class represents a different kind of ball. Different kinds of balls can behave in different ways.

  • One kind of ball might bounce around the screen.
  • Another might grow and shrink in size.
  • Still another might sit still until you grab it with the mouse and drag it around.
Each of these kinds corresponds to a different class. You can, of course, have multiple balls of each of these kinds -- multiple instances of each of these classes.

As is typical in software development, BallWorlds will be developed by a team:

  • We will supply a framework.
  • You will supply a class for each type of Ball.

We will coordinate our work by using this UML class diagram for BallWorlds.

In particular, the class diagram specifies how your Ball classes interface with the framework.

ALL that you need to do to make BallWorlds work correctly is to:

  1. Implement the three interfaces (Animate, Drawable, Relocatable) that each Ball class must implement.
    • Each type of Ball implements these interfaces in its own way. That is, the methods of the interfaces must be implemented in a way that is meaningful to the type of Ball that you are working on.

  2. Each Ball must add itself to its World, by using the BallEnvironment object that it is given in its constructor.

This project is based on ideas from Lynn Andrea Stein's Rethinking CS101 project.