package class2_1_DuckFactories_v6; import class2_1_DuckFactories_v6.swimBehaviors.*; import class2_1_DuckStrategies_v7.StandardSwimming; /** * 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) { SwimBehaviorFactory standardFactory = new StandardSwimBehaviorFactory(); SwimBehaviorFactory horizFactory = new HorizontalSwimBehaviorFactory(); // create some ducks Duck donald = new Duck("Donald",standardFactory); Duck clyde = new Duck("Clyde",horizFactory); // Duck woody = new Duck("Woody",swimBehavior); // Duck buster = new Duck("Buster",swimBehavior); // Duck donald = Duck.userSpecifiedDuck(); 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 */ } } } }