예제 #1
0
파일: Program.cs 프로젝트: BernCS/lab12
        static void Menu2()
        {
            int option = -1;

            while (option != 0)
            {
                Console.Clear();
                Console.WriteLine("1) Создать список.");
                Console.WriteLine("2) Вывести список.");
                Console.WriteLine("3) Добавить в список элемент после элемента с заданным информационным ");
                Console.WriteLine("4) Удалить список из памяти.");
                Console.WriteLine("0) Выход.");
                Console.WriteLine("Выберите опцию: ");
                option = Input.Int(0, 5);
                switch (option)
                {
                case 0:
                    return;

                    break;

                case 1:
                    Console.WriteLine("Введите размер списка: ");
                    node2 = new Node2();
                    node2.MakeNode(Input.Int(1, 100000));;
                    Console.WriteLine("Список создан.");
                    break;

                case 2:
                    if (node2 == null)
                    {
                        Console.WriteLine("Объект пуст.");
                    }
                    else
                    {
                        node2.Print();
                    }
                    break;

                case 3:
                    Console.WriteLine("Введите элемент для поиска: ");
                    Country a = new Country();
                    Console.WriteLine("Введите элемент для добавления: ");
                    node2.Add(a, new Country());
                    break;

                case 4:
                    node2.Dispose();
                    node2 = null;
                    Console.WriteLine("Список удален из памяти");
                    break;
                }
                Console.ReadKey();
            }
        }
예제 #2
0
파일: Node2.cs 프로젝트: BernCS/lab12
        public void MakeNode(int size)
        {
            if (size == 0)
            {
                return;
            }

            Data      = new Country();
            Next      = new Node2();
            Next.Pred = this;
            Next.MakeNode(size - 1);
        }