package class1_3_DuckStrategies_v0; /** * This Duck simulation application is going to go viral * @author hornick * copyright, because this will make a boatload of ca$h. */ public class SimUDuckApp { /** * @param args - not used */ public static void main(String[] args) { DuckPond pond = new DuckPond("Angry angry ducks"); // note catchy name // create some ducks Duck daffy = new Duck("Daffy"); Duck donald = new Duck("Donald"); Duck clyde = new Duck("Clyde"); // put them in the pond pond.addDuck(daffy); pond.addDuck(donald); pond.addDuck(clyde); // We should really only deal with GUI objects from the "event dispatch thread" // But we haven't talked about threading yet, so please trust us that this works. while(true) { // loop forever daffy.swim(); // each swim() call makes the ducks move a little bit donald.swim(); clyde.swim(); pond.repaint(); // update the window display after the ducks move try { Thread.sleep(50); // pause for 50ms } catch(InterruptedException e) { // not used; but required in case something wakes us from our 50ms nap /* yawn */ } } } }