// Flocking // Daniel Shiffman // Flock class // Does very little, simply manages the ArrayList of all the boids // Created 2 May 2005 class Flock { ArrayList boids; // An arraylist for all the boids ArrayList boids2; ArrayList boids3; Flock() { boids = new ArrayList(); // Initialize the arraylist boids2 = new ArrayList(); boids3 = new ArrayList(); } void run() { for (int i = 0; i < boids.size(); i++) { Boid b = (Boid) boids.get(i); b.run(boids); // Passing the entire list of boids to each boid individually } for (int i = 0; i < boids2.size(); i++) { Boid2 b2 = (Boid2) boids2.get(i); b2.run(boids2); } for (int i = 0; i < boids3.size(); i++) { Boid3 b3 = (Boid3) boids3.get(i); b3.run(boids3); } } void addBoid(Boid b) { boids.add(b); } void addBoid2(Boid2 b2) { boids2.add(b2); } void addBoid3(Boid3 b3) { boids3.add(b3); } }