using System;
namespace 简单工厂设计模式//(抽象类实现的多态)
{
class Program
{
static void Main(string[] args)
{
string brand = Console.ReadLine();
NoteBook cosm = GetNoteBook(brand);
cosm.Say();
}
public static NoteBook GetNoteBook(string brand)
{
NoteBook nb = null;
switch(brand)
{
case "Lenovo":nb = new Lenovo();
break;
case "Acre":nb = new Acre();
break;
case "IBM":nb = new IBM();
break;
}
return nb;
}
public abstract class NoteBook
{
public abstract void Say();
}
public class Lenovo : NoteBook
{
public override void Say()
{
Console.WriteLine("Lenovo");
}
}
public class Acre:NoteBook
{
public override void Say()
{
Console.WriteLine("Acre");
}
}
public class IBM:NoteBook
{
public override void Say()
{
Console.WriteLine("IBM");
}
}
}
}