一、问题描述
学习享元模式,做实例演示(围棋的黑子白子)的出现了一个问题,主要代码如下:
import java.util.*;
public class IgoChessmanFactory {
private Hashtable ht;
public IgoChessmanFactory() {
ht = new Hashtable();
IgoChessman black, white;
black = new BlackIgoChessman();
white= new WhiteIgoChessman();
ht.put('b', black);
ht.put('w', white);
}
public IgoChessman getIgoChessman(String color)
{
return (IgoChessman