예제 #1
0
        static void Main(string[] args)
        {
            string enemyName = args[0];

            EnemyFactory enemyFactory = new EnemyFactory();

            // now the main class 'program' isn't aware of
            // the enemy types anymore (good)
            // but its aware of the particular factory (bad)
            IEnemy enemy = enemyFactory.CreateInstance(enemyName.ToLower());

            enemy.Attack();
            enemy.Die();
        }