标签:
{
public ProductA createProductA();
public ProductB createProductB();
}
//抽象产品类A
public interface AbstractProductA
{
}
//抽象产品类B
public interface AbstractProductB
{
}
//具体产品类ProdcutA1
public class ProductA1 implements AbstractProductA
{
public ProductA1()
{
}
}
//具体产品类ProdcutA2
public class ProductA2 implements AbstractProductA
{
public ProductA2()
{
}
}
//具体产品类ProductB1
public class ProductB1 implements AbstractProductB
{
public ProductB1()
{
}
}
//具体产品类ProductB2
public class ProductB2 implements AbstractProductB
{
public ProductB2()
{
}
}
//具体工厂类1
public class ConcreteFactory1 implements AbstractFactory{
public AbstractProductA createProductA(){
return new ProductA1();
}
public AbstractProductB createProductB(){
return new ProductB1();
}
}
//具体工厂类2
public class ConcreteFactory2 implements Creator{
public AbstractProductA createProductA(){
return new ProductA2();
}
public AbstractProductB createProductB(){
return new ProductB2();
}
}
标签:
原文地址:http://www.cnblogs.com/elain/p/4314207.html