예제 #1
0
        public static Maze createMaze(MazeFactory mf)
        {
            Maze m = mf.makeMaze(5, 5);

            for (int x = 0; x < 5; x++)
            {
                for (int y = 0; y < 5; y++)
                {
                    m.addComponent(mf.makeWall(), x, y);
                }
            }
            m.addComponent(mf.makeRoom(), 1, 2);
            m.addComponent(mf.makeRoom(), 2, 2);
            m.addComponent(mf.makeRoom(), 3, 2);
            m.addComponent(mf.makeRoom(), 1, 1);
            m.addComponent(mf.makeRoom(), 3, 1);
            m.addComponent(mf.makeRoom(), 1, 3);
            m.addComponent(mf.makeRoom(), 3, 3);

            return(m);
        }
예제 #2
0
        static void Main(string[] args)
        {
            MazeFactory mf    = null;
            String      input = Console.ReadLine();

            if (input.Equals("maze"))
            {
                mf = new MazeFactory();
            }
            else if (input.Equals("coin"))
            {
                mf = new CoinFactory();
            }
            else
            {
                Environment.Exit(0);
            }

            Maze m = createMaze(mf);

            m.printMaze();
            Console.ReadLine();
        }