static void Main(string[] args) { Console.WriteLine("请输入你喜欢的笔记本电脑名称:"); string brand = Console.ReadLine(); NoteBook nb = CreateNoteBook(brand); nb.Show(); Console.ReadKey(); }
//创建笔记本的工厂 public static NoteBook CreateNoteBook(string brand) { NoteBook nb = null; switch (brand) { case "lenovo": nb = new Lenovo(); break; } return(nb); }