//当基类和子类的类型不一致时,会提示“不一致的存取范围”
//Sample如下:
//只有在abstract前也加上public时候才能通过
//定义一个抽象类
abstract class CashSuper
{
public abstract double acceptCash(double money);
}
//收费工厂
public class CashSuperFactory
{
public static CashSuper createCashAccept(string type)
{
CashSuper cs = null;
switch (type)
{
case "正常收费":
cs = new CashNormal();
break;
case "打8折":
CashRebate cr1 = new CashRebate("0.8");
cs = cr1;
break;
case "满300送100":
CashReturn cr2 = new CashReturn("300", "100");
cs = cr2;
break;
}
return cs;
}
}