Exemplo n.º 1
0
        static void Main(string[] args)
        {
            SimpleMonsterBallFactory mon = new SimpleMonsterBallFactory();
            MonsterBall m = mon.createMonsterBall("MonsterBall3 ");

            Console.WriteLine(m.Speed);
        }
        public MonsterBall createMonsterBall(string type)
        {
            MonsterBall mb = null;

            if (type.Equals("MonsterBall1"))
            {
                mb = new MonsterBall1();
            }
            else if (type.Equals("MonsterBall2"))
            {
                mb = new MonsterBall2();
            }
            else
            {
                mb = new MonsterBall3();
            }
            return(mb);
        }