Ejemplo n.º 1
0
 public static void PrintInfo(game mas, int size)
 {
     for (int i = 0; i < size; i++)
     {
         for (int j = 0; j < size; j++)
         {
             Console.Write("{0}\t", mas[i, j]);
         }
         Console.WriteLine();
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //string path = "C:\\Users\\user\\Desktop\\1.txt";
            //string path = null;
            //TextFile.TextToGame(path);

            int[] tiles = new int[9] {
                1, 5, 6, 4, 0, 2, 7, 8, 3
            };
            game puzzle = new game(tiles);

            //puzzle.Shift(1);
            puzzle.GetLocation(99);
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        static public void StartTheGame()
        {
            Random gen = new Random();

            Console.WriteLine("Введите число, размер поля");
            string s      = Console.ReadLine();
            int    number = Convert.ToInt32(s);
            game   player = new game(number);

            player.Fillig(gen);
            Console.Clear();
            while (!player.CheckingSequence())
            {
                player.Printing();
                Console.WriteLine("Выберете число,которое хотите передвинуть");
                int value = Convert.ToInt16(Console.ReadLine());
                player.Shift(value);
                Console.Clear();
            }
            player.Printing();
            Console.WriteLine("Вы выиграли");
        }
Ejemplo n.º 4
0
        public static void TextToGame(string path)
        {
            if (path != null)
            {
                string   file = File.ReadAllText(path);
                string[] chars;
                chars = file.Split(new char[] { ' ', ',', '\t', '\n' });
                int[] tiles = new int[chars.Length];
                int   n     = 0;

                for (int i = 0; i < chars.Length; i++)
                {
                    tiles[i] = Convert.ToInt32(chars[n]);
                    n++;
                }

                game puzzle = new game(tiles);
            }

            else
            {
                throw new NullReferenceException("Ошибка: ссылка на расположение файла отсутствует");
            }
        }