抽象工厂类的代码如下:
1using System;
2using System.Reflection;
3
4namespace AbstractFactory
5{
6 /**//// <summary>
7 /// AbstractFactory类
8 /// </summary>
9 public abstract class AbstractFactory
10 {
11 public static AbstractFactory GetInstance()
12 {
13 string factoryName = Constant.STR_FACTORYNAME.ToString();
14
15 AbstractFactory instance;
16
17 if(factoryName == "ChineseFactory")
18 instance = new ChineseFactory();
19 else if(factoryName == "AmericanFactory")
20 instance = new AmericanFactory();
21 else
22 instance = null;
23
24 return instance;
25 }
26
27 public abstract Tax CreateTax();
28
29 public abstract Bonus CreateBonus();
30 }
31}
文章来源于领测软件测试网 https://www.ltesting.net/