package ballworlds.framework; import java.awt.Color; import java.awt.Dimension; import java.util.ArrayList; /** * The BallWorlds application is a Swing application that simulates "worlds" * that contain various kinds of "balls" (and possibly other objects). * *
* The BallWorlds class contains the main method for the BallWorlds application * and hence is the starting point for that application. * * It constructs the Worlds and the frame in which they will be displayed. * *
* This exercise is based on an exercise from Lynn Andrea Stein's Rethinking CS101 project.
*
* @author David Mutchler, Salman Azhar and others, January 2005.
* Modified September, 2008.
*/
public class BallWorlds {
/* Default number, sizes and colors for the Worlds. */
private static int numberOfWorlds = 3;
private static Dimension world1Size = new Dimension(850, 250);
private static Dimension world2Size = new Dimension(600, 450);
private static Dimension world3Size = new Dimension(350, 250);
private static Color world1Color = new Color(0, 255, 126);
private static Color world2Color = new Color(0, 126, 255);
private static Color world3Color = new Color(0, 225, 0);
/**
* The BallWorlds application starts here in main.
* It constructs the Worlds and the frame in which they will be displayed.
*
* @param args Array of command-line arguments
*/
public static void main(String[] args) {
BallWorldsFrame frame;
frame = new BallWorldsFrame();
BallWorlds.makeWorlds(BallWorlds.numberOfWorlds, frame);
frame.setVisible(true);
}
/*
* Makes the given number of Worlds, giving each the given frame.
* Rotates between 3 preassigned sizes and colors for the Worlds.
*/
private static void makeWorlds(int numberOfWorlds, BallWorldsFrame frame) {
ArrayList