籃球 翻譯 轉接器I

籃球 翻譯 轉接器I

籃球 翻譯 轉接器I

籃球 翻譯 轉接器I

abstract class Player
{
protected string name;

public Player(string name)

{

this.name = name;

}

public abstract void Attack();

public abstract void Defense();

}

class Forwards : Player
{

public Forwards(string name) : base(name)
{
}

public override void Attack()
{
    Console.WriteLine(”前鋒 {0} 進攻”, name);
}

public override void Defense()
{
    Console.WriteLine(”前鋒 {0} 防守”, name);
}

}

class Center : Player
{

}

class Guards : Player
{

}

static void Main(string[] args)
{

Player b = new Forwards(”巴蒂爾”);

b.Attack();

Player m = new Guards(”麥克格雷迪”);

m.Attack();

Player ym = new Center(”姚明”);

ym.Attack();

ym.Defense();

Console.Read();

}

假設姚明剛來到NBA,但他還不懂英語,Attack和Defense不明其意。

就必須要有一個轉譯器;翻譯者類別來轉接。