通过工厂方法实现字母表是不是好主意?
例子:
public class Alphabet
{
public Alphabet(image picture, string name)
{
_picture = picture;
_name = name;
}
public void Show()
{
_picture.Show();
}
}
public LetterA: Alphabet
{
public LetterA() : Alphabet("lttrA.png", "Letter A"){}
}
....
public LetterZ: Alphabet
{
public LetterZ() : Alphabet("lttrZ.png", "Letter Z"){}
}
使用:
Alphabet ltr1 = new LetterA();
要求:图片永不改变,以后无添加方法
谢谢