using System;
using System.Collections.Generic;
using System.Text;
namespace 抽象类应用
{
/// 
/// NPC类型枚举
/// 
public enum NPCType
{
Task,
Shop,
Fod
}
/// 
/// 定义一个抽象类
/// 
/// 抽象类不能被实例化,因为抽象类中有抽象方法(无方法体),
/// 如果真能实例化抽象对象,调用这些方法体的方法无任何意义。
abstract class NPCs
{
private string name;
private NPCType type;
    public string Name { get { return name; } set { name = value; } }
    public NPCType  Type { get { return type ; } set { type  = value; } }
    public NPCs (string name ,NPCType type)
    {
        Name = name;
        Type = type;
    }
    /// 抽象类中不一定要有抽象方法,但抽象方法必须要定义在抽象类中
    /// 抽象方法的方法体为空
    public abstract void Speek();
    
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace 抽象类应用
{
class TaskNPC : NPCs
{
private string taskInfo;
    public TaskNPC (string taskInfo,string name,NPCType type)
        :base (name ,type )
    {
        this.taskInfo = taskInfo;
    }
    //继承抽象类,“必须”实现抽象类中的抽象方法。否则程序无法运行。
    public override void Speek()
    {
        Console .WriteLine ("NPC:{0},任务:{1}" ,Name,taskInfo );
    }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace 抽象类应用
{
class ShopNPC : NPCs
{
private string item;
    public ShopNPC (string item, string name, NPCType type)
       : base(name, type)
    {
        this.item  = item ;
    }
    public override void Speek()
    {
        Console.WriteLine("NPC:{0},贩卖{1}产品", base.Name, item);
    }
}
}
//程序实现
using System;
namespace 抽象类应用
{
class Program
{
static void Main(string[] args)
{
//NPCs n = new NPCs("灰太狼", NPCType.Shop);//抽象类不能被实例化,
        TaskNPC t1 = new TaskNPC("让你去挖大头菜","老八", NPCType.Task);
        t1.Speek();
        ShopNPC s1 = new ShopNPC("喜洋洋", "灰太狼", NPCType.Shop);
        s1.Speek();   
    }
}
}