private void inputcommand(string inpuT)
        {
            if (inpuT[0] == 'f' && inpuT.Length == 4)
            {
                int col = inpuT[2] - 97; // 97 = A
                int row = inpuT[3] - 48; //  48 = 0
                board.TryFlag(row, col);
            }

            if (inpuT[0] == 'r' && inpuT.Length == 4)
            {
                int col = inpuT[2] - 97; // 97 = A
                int row = inpuT[3] - 48; //  48 = 0
                board.TrySweep(row, col);
            }

            if (inpuT[0] == 'q')
            {
                quit = true;
            }
            else if (inpuT[0] != 'r' && inpuT[0] != 'f' && inpuT.Length != 4)
            {
                System.Console.WriteLine("unknown Command");
            }
        }
Example #2
0
        private bool ExecuteCommand(string input)
        {
            //om f så ska den flagga
            if (input[0] == 'f')
            {
                if (input.Length == 1)
                {
                    System.Console.WriteLine("syntax error");
                    return(false);
                }
                int col = input[2] - 97;// A=0 B=1 C=3 osv
                int row = input[3] - 48;
                return(board.TryFlag(row, col));
            }
            // om r så ska den sweepa
            if (input[0] == 'r')
            {
                if (input.Length == 1)
                {
                    System.Console.WriteLine("syntax error");
                    return(false);
                }
                int col = input[2] - 97;// A=0 B=1 C=3 osv
                int row = input[3] - 48;
                return(board.TrySweep(row, col));
            }

            // om q så ska den quita
            if (input[0] == 'q')
            {
                return(quit = true);
            }
            else if (input[0] != 'f' && input[0] != 'r')
            {
                System.Console.WriteLine("unknow command");
            }
            return(true);
        }