Exemple #1
0
    public AChessman GetChessMan(string chess)
    {
        AChessman res = null;

        if (!mCache.ContainsKey(chess))
        {
            switch (chess)
            {
            case "black":
                res = new BlackChessman();
                break;

            case "white":
                res = new WhiteChessman();
                break;

            default:
                break;
            }
            mCache[chess] = res;
        }
        else
        {
            res = mCache[chess];
        }

        return(res);
    }
            static ChessmanFactory()
            {
                Instance   = new ChessmanFactory();
                hsChessman = new Hashtable();

                Chessman black, white;

                black = new BlackChessman();
                hsChessman.Add(Color.Black, black);
                white = new WhiteChessman();
                hsChessman.Add(Color.White, white);
            }