package class2_1_DuckStrategies_v7_Factory; import class2_1_DuckStrategies_v7_Factory.ducks.*; import java.util.Scanner; /** * 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); pond.addDuck(Duck.createDuck(new Scanner(System.in))); while(true) { // loop forever // TODO: Make all ducks in pond swim! // donald.performSwimming(); // each swim() call makes the ducks move a little bit // clyde.performSwimming(); // woody.performSwimming(); // buster.performSwimming(); 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 */ } } } }