/* * Open Source Physics software is free software as described near the bottom of this code file. * * For additional information and documentation on Open Source Physics please see: * */ package org.opensourcephysics.sip.ch02; import org.opensourcephysics.controls.*; import org.opensourcephysics.frames.*; /** * BouncingBall models a collection of bouncing balls. * * @author Wolfgang Christian, Jan Tobochnik, Harvey Gould * @version 1.0 05/07/05 */ public class BouncingBallApp extends AbstractSimulation { // declares and instantiates a window to draw balls DisplayFrame frame = new DisplayFrame("x", "y", "Bouncing Balls"); PlotFrame KE = new PlotFrame("t", "KE","BouncingBalls"); BouncingBall[] ball; // declares an array of BouncingBall objects double time, dt; /** * Initializes the simulation by creating the BouncingBall objects and adding them * to the frame. */ public void initialize() { // sets boundaries of window in world coordinates frame.setPreferredMinMax(-10.0, 10.0, 0, 10); time = 0; frame.clearDrawables(); // removes old particles int n = control.getInt("number of balls"); int v = control.getInt("speed"); ball = new BouncingBall[n]; // instantiates array of n BouncingBall objects for(int i = 0;i