Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Program start\n");

            SudokuGrid sg;

            while (true)
            {
                Console.WriteLine("Enter quadratic Sudoku size ('x' to quit):\t");
                String input = Console.ReadLine();
                if (input == "x")
                {
                    break;
                }
                int sudokuSize = Convert.ToInt32(input);

                sg = new SudokuGrid(sudokuSize);
                sg.fillEntireSudokuGrid();

                String sgAsString = sg.ToString();

                Console.WriteLine(sgAsString);
            }

            Console.WriteLine("\nProgram end");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void SudokuGridConstructorTest()
        {
            SudokuGrid sg1 = new SudokuGrid(4);

            try
            {
                SudokuGrid sg2 = new SudokuGrid(0);
                Assert.Fail("SudokuGrid with size 0 should have thrown an exception!");
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            try
            {
                SudokuGrid sg2 = new SudokuGrid(5);
                Assert.Fail("SudokuGrid with nonsquare size 5 should have thrown an exception!");
            }
            catch (ArgumentException)
            {
            }
        }