Exemplo n.º 1
0
        public BasicBoardComponent Create(ComponentsEnum a_moveableEnum, int row, int col)
        {
            BoardComponentFactoryMethod factoryMethod = null;

            if (!factory.TryGetValue(a_moveableEnum, out factoryMethod))
            {
                throw new Exception($"No factory method was found for ${a_moveableEnum}");
            }
            return(factoryMethod(row, col));            // Creating the Object
        }
Exemplo n.º 2
0
        /// <summary>
        /// adding or replace components to your PC
        /// </summary>
        /// <param name="componentType"></param>
        /// <param name="name"></param>
        /// <param name="price"></param>
        /// <param name="details"></param>

        public void AddOrReplaceComponent(ComponentsEnum componentType, string name, decimal price, string details)
        {
            if (componentType == ComponentsEnum.Processor)
            {
                this.Processor = new Component(name, price, details);
            }

            if (componentType == ComponentsEnum.GraphicsCard)
            {
                this.GraphicsCard = new Component(name, price, details);
            }

            if (componentType == ComponentsEnum.Motherboard)
            {
                this.Motherboard = new Component(name, price, details);
            }
        }
        /// <summary>
        /// adding or replace components to your PC
        /// </summary>
        /// <param name="componentType"></param>
        /// <param name="name"></param>
        /// <param name="price"></param>
        /// <param name="details"></param>

        public void AddOrReplaceComponent(ComponentsEnum componentType, string name, decimal price, string details)
        {
            if (componentType == ComponentsEnum.Processor)
            {
                this.Processor = new Component(name, price, details);
            }

            if (componentType == ComponentsEnum.GraphicsCard)
            {
                this.GraphicsCard = new Component(name, price, details);
            }

            if (componentType == ComponentsEnum.Motherboard)
            {
                this.Motherboard = new Component(name, price, details);
            }
        }
Exemplo n.º 4
0
        public ComponentsEnum[,] GetLevel(int difficulty)
        {
            string[] dbBoard;
            ComponentsEnum[,] formattedBoard;
            if (!m_database.TryGetValue(difficulty, out dbBoard))
            {
                throw new Exception($"The Level Provider do not contain a level with dificulty of ${difficulty}");
            }

            int rows = dbBoard.Length;
            int cols = dbBoard.FirstOrDefault().Length;

            formattedBoard = new ComponentsEnum[rows, cols];    // Creating the board
            for (int rowIndex = 0; rowIndex < rows; rowIndex++)
            {
                for (int colIndex = 0; colIndex < cols; colIndex++)
                {
                    char componentType = dbBoard[rowIndex][colIndex];
                    formattedBoard[rowIndex, colIndex] = m_dbToTypeConverter[componentType];
                }
            }
            return(formattedBoard);      // Return the board
        }