Ejemplo n.º 1
0
        /// <summary>
        /// Creates labyrinth of type asked by the user
        /// </summary>
        /// <param name="userChoiceOfLabyrinth">Type of labyrinth asked by user</param>
        /// <returns>Returns a labyrinth of type as given in parameter with name "userChoiceOfLabyrinth"</returns>
        public ILabyrinth Create(string userChoiceOfLabyrinth)
        {
            // Ninject used to get contracted class
            var kernel = new StandardKernel();

            kernel.Load(Assembly.GetExecutingAssembly());
            var randomGenerator = kernel.Get <IRandomCharProvider>();

            TypeLabyrinth typeOfLabyrinth = this.GetLabyrinthType(userChoiceOfLabyrinth);
            ILabyrinth    labyrinth       = this.CreateRequiredLabyrinth(typeOfLabyrinth);

            labyrinth.FillMatrix(randomGenerator);

            return(labyrinth);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates user required labyrinth
        /// </summary>
        /// <param name="typeLabyrinth">string representation of concrete labyrinth</param>
        /// <returns>Instance of the selected labyrinth</returns>
        private ILabyrinth CreateRequiredLabyrinth(TypeLabyrinth typeLabyrinth)
        {
            switch (typeLabyrinth)
            {
            case TypeLabyrinth.Diamond:
                return(new DiamondLabyrinth());

            case TypeLabyrinth.Pentagram:
                return(new PentagonLabyrinth());

            case TypeLabyrinth.Hexagon:
                return(new HexagonalLabyrinth());

            case TypeLabyrinth.Square:
                return(new SquareLabyrinth());

            default:
                throw new ArgumentException("Not specified labyrinth");
            }
        }