抽象工厂模式【ABSTRACT FACTORY PATTERN】test
import AbstractFactory.Sample.factory.*;public class Main{ public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: java Main class.name.of.ConcreteFactory"); System.out.println("Example 1: java Main AbstractFactory.Sample.listfactory.ListFactory"); System.out.println("Example 2: java Main AbstractFactory.Sample.tablefactory.TableFactory"); System.exit(0); } Factory factory = Factory.getFactory(args[0]); Link nba = factory.createLink("China NBA", "http://www.nba.china.com/"); Link sohu = factory.createLink("SOHU Sport ", "http://www.sohu.sport.com/"); Link apache = factory.createLink("Apache", "http://www.apache.org"); Link qq = factory.createLink("QQ", "http://www.qq.com/"); Link hk = factory.createLink("Google HK", "http://www.google.com.hk/"); Link google = factory.createLink("Google", "http://www.google.com/"); Tray root1 = factory.createTray("favorite"); root1.add(nba); root1.add(sohu); root1.add(qq); Tray g = factory.createTray("Google city country"); g.add(hk); g.add(google); Tray d = factory.createTray("directory"); d.add(apache); Tray root2 = factory.createTray("Google"); root2.add(g); root2.add(d); Page page = factory.createPage("LinkPage", "albert"); page.add(root1); page.add(root2); page.output(); }}