package class1_3_DuckStrategies_v5; /** * 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) { // create some ducks Duck donald = new Mallard("Donald"); Duck clyde = new Redhead("Clyde"); Duck woody = new Decoy("Woody"); Duck buster = new RubberDuck("Buster"); // DuckPond pond = new DuckPond("Angry angry ducks"); // note catchy name // put them in the pond pond.addDuck(donald); pond.addDuck(clyde); pond.addDuck(woody); pond.addDuck(buster); while(true) { // loop forever donald.swim(); // each swim() call makes the ducks move a little bit clyde.swim(); woody.swim(); buster.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 */ } } } }