vs2005+C#+.net 2.0
提供一个创建一系列相关或相互依赖的接口,而无需指定他们具体的类,抽象工厂(abstract factory)模式又称kti模式。
using
System;
using System.Collections.Generic;
using System.Text;
namespace AbatractFactoryPattern
... {
abstract class AbstractProductA
...{
}
abstract class AbstractProductB
...{
}
abstract class Factory
...{
abstract public void GenerateProductFamily();
}
class ProductA1:AbstractProductA
...{
}
class ProductA2 : AbstractProductA
...{
}
class ProductB1 : AbstractProductB
...{
}
class ProductB2 : AbstractProductB
...{
}
class Factory1 : Factory
...{
public override void GenerateProductFamily()
...{
}
}
class Factory2 : Factory
...{
public override void GenerateProductFamily()
...{
}
}
class Client
...{
public void GenerateFactory()
...{
}
}
class Test
...{
static void Main(string[] args)
...{
}
}
}
using System.Collections.Generic;
using System.Text;
namespace AbatractFactoryPattern
... {
abstract class AbstractProductA
...{
}
abstract class AbstractProductB
...{
}
abstract class Factory
...{
abstract public void GenerateProductFamily();
}
class ProductA1:AbstractProductA
...{
}
class ProductA2 : AbstractProductA
...{
}
class ProductB1 : AbstractProductB
...{
}
class ProductB2 : AbstractProductB
...{
}
class Factory1 : Factory
...{
public override void GenerateProductFamily()
...{
}
}
class Factory2 : Factory
...{
public override void GenerateProductFamily()
...{
}
}
class Client
...{
public void GenerateFactory()
...{
}
}
class Test
...{
static void Main(string[] args)
...{
}
}
}