// a class which controls the Termites population arraylist class kWorld { ArrayList population; ArrayList mudpop; ArrayList dudpop; ArrayList attractors; ArrayList pheremones; kWorld() { population = new ArrayList(); mudpop = new ArrayList(); dudpop = new ArrayList(); attractors = new ArrayList(); pheremones = new ArrayList(); } // cycles through each Termites passing the population to it void run(){ for (int i = 0; i < population.size(); i++) { kTermites a = (kTermites) population.get(i); a.step(this); } } // adds an obstacle to the mudpop array list void addMud(kMud o) { mudpop.add(o); } // adds an Termites to the population void addTermites(kTermites a) { population.add(a); } // adds an obstacle to the mudpop array list void addDud(kDud o) { dudpop.add(o); } // adds an attractor to the attractor array list void addPheremone(kPheremone p) { pheremones.add(p); } // calls render methods for all objects in the world void render(){ // Termitess for (int i = 0; i < population.size(); i++) { kTermites a = (kTermites) population.get(i); a.render(); } // mudpop for (int i = 0; i < mudpop.size(); i++) { kMud o = (kMud) mudpop.get(i); o.render(); } // dudpop for (int i = 0; i < dudpop.size(); i++) { kDud o = (kDud) dudpop.get(i); o.render(); } // pheremones for (int i = 0; i < pheremones.size(); i++) { kPheremone p = (kPheremone) pheremones.get(i); p.render(); } } }