import java.awt.*; import java.awt.event.*; import java.applet.*; public class MassiveBall extends SimulationApplet { static final double r_max=50,r_mid=20,r_min=10; Ball[] large=new Ball[5]; Ball[] small=new Ball[150]; Ball[] all=new Ball[large.length+small.length]; Grid grid; Ball seized; public void init() { super.init(); int i=0; for (int j=0;jwidth-r) { if (u>0) u*=-elasticity; x+=bounce*(width-r-x); } if (yheight-r) { if (v>0) v*=-elasticity; y+=bounce*(height-r-y); } } } class Grid { private double width,height,delta; private int cols,rows,capacity; private Object[][][] cell; private int[][] count; public Grid(double width,double height,double delta,int capacity) { this.width=width; this.height=height; this.delta=delta; this.capacity=capacity; cols=(int)Math.ceil(width/delta); rows=(int)Math.ceil(height/delta); cell=new Object[cols][rows][capacity]; count=new int[cols][rows]; } public void clear() { for (int i=0;i=cols) i=cols-1; if (j<0) j=0; if (j>=rows) j=rows-1; if (count[i][j]