Exemplo n.º 1
0
        private Cell[] CreateBoard(int boardSize)
        {
            Cell[] board = new Cell[boardSize];
            for (int i = 0; i < boardSize; i++)
            {
                Cell c = new Cell();
                c.CellNumber = i + 1;
                board[i]     = c;
            }
            bool isSnakeCellLeft = true;

            while (isSnakeCellLeft)
            {
                Console.WriteLine("Want to define a snake (~~~~~~~~~@) y/n");
                if (Console.ReadLine().ToLower() == "y")
                {
                    Console.WriteLine("Snake cell number");
                    int snakeCellNumber = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Penalty cell number");
                    int       penaltyCellNumber = Convert.ToInt32(Console.ReadLine());
                    SnakeCell s = new SnakeCell();
                    s.CellNumber  = snakeCellNumber;
                    s.PenaltyCell = penaltyCellNumber;
                    board[snakeCellNumber - 1] = s;
                }
                else
                {
                    isSnakeCellLeft = false;
                }
            }

            bool isLadderCellLeft = true;

            while (isLadderCellLeft)
            {
                Console.WriteLine("Want to define a ladder (|-|-|-|-|-|-|) y/n");
                if (Console.ReadLine().ToLower() == "y")
                {
                    Console.WriteLine("Ladder cell number");
                    int ladderCellNumber = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Advantage cell number");
                    int        advantageCellNumber = Convert.ToInt32(Console.ReadLine());
                    LadderCell l = new LadderCell();
                    l.CellNumber                = ladderCellNumber;
                    l.AdvantageCell             = advantageCellNumber;
                    board[ladderCellNumber - 1] = l;
                }
                else
                {
                    isLadderCellLeft = false;
                }
            }
            return(board);
        }
Exemplo n.º 2
0
        private Cell[] CreateBoard(int boardSize)
        {
            Cell[] board = new Cell[boardSize];
            for (int i = 0; i < boardSize; i++)
            {
                Cell c = new Cell();
                c.NumeroCelda = i + 1;
                board[i]      = c;
            }
            bool isSnakeCellLeft = true;



            bool isLadderCellLeft = true;

            while (isLadderCellLeft)
            {
                Console.WriteLine("Quiere definir la escalera?? (|-|-|-|-|-|-|) s/n");
                if (Console.ReadLine().ToLower() == "s")
                {
                    Console.WriteLine("Numero de celda donde se va a encontrar la escalera");
                    int ladderCellNumber = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Ventaja por el numero de celda");
                    int        advantageCellNumber = Convert.ToInt32(Console.ReadLine());
                    LadderCell l = new LadderCell();
                    l.NumeroCelda  = ladderCellNumber;
                    l.CeldaVentaja = advantageCellNumber;
                    board[ladderCellNumber - 1] = l;
                }
                else
                {
                    isLadderCellLeft = false;
                }
            }
            return(board);
        }