抽象工厂模式【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();
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值