package class5_1_DuckFactories_v7; import class5_1_DuckFactories_v7.swimBehaviors.*; /** * This Ball 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 Duck.HorizontalSwimBehaviorFactory(); // create some ducks Duck donald = new Duck("Donald",standardFactory); Duck clyde = new Duck("Clyde",horizFactory); // Ball woody = new Ball("Woody",swimBehavior); // Ball buster = new Ball("Buster",swimBehavior); // Ball donald = Ball.userSpecifiedDuck(); DuckPond pond = new DuckPond("Angry angry ducks"); // note catchy name // put them in the pond pond.addDuck(donald); pond.addDuck(clyde); // pond.addBall(woody); // pond.addBall(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 */ } } } }