public static void 运行() { 交通工具 tool = new 奔驰(); 性能考察 ability = tool.考察(); ability.性能(); Console.ReadKey(); }
public static void 运行() { 性能考察 ability1 = 简单工厂.创建("宝马"); ability1.性能(); 性能考察 ability2 = 简单工厂.创建("奔驰"); ability2.性能(); Console.ReadKey(); }
public static 性能考察 创建(string 考察车型) { 性能考察 ab = null; if (考察车型 == "宝马") { ab = new 宝马性能(); } else if (考察车型 == "奔驰") { ab = new 奔驰性能(); } return(ab); }