/** * This is to demonstrate abstract factory classes. * * @author Bob Futrelle * @version 1.0 7/12/2002 * */ public class AbstractFactoryTest { public static void main(String[] args) { Dog dog; DogHouse dogHouse; DogFood dogFood; DogShoppingTrip theTrip; // Create the factory TripFactory trips = new TripFactory(); // Get a little dog shopping trip theTrip = trips.getTrip(DogShoppingTrip.LITTLE); say("Here's the info for the little dog shopping excursion:\n"); dog = theTrip.buyDog(); dog.speak(); dogHouse = theTrip.buyDogHouse(); dogHouse.describe(); dogFood = theTrip.buyDogFood(); dogFood.describe(); // Get a BIG DOG shopping trip theTrip = trips.getTrip(DogShoppingTrip.BIG); say("\nHere's the info for the BIG DOG shopping excursion:\n"); // Note: code below is the same as the above dog = theTrip.buyDog(); dog.speak(); dogHouse = theTrip.buyDogHouse(); dogHouse.describe(); dogFood = theTrip.buyDogFood(); dogFood.describe(); } // main() static void say(String s) { System.out.println(s); } }