예제 #1
0
        static void Main(string[] args)
        {
            linkedList programList = new linkedList();

            int userInput;

            Console.WriteLine("add items to list and look at list");

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("1.show head");
                Console.WriteLine("2.add items");
                Console.WriteLine("3.remove items");
                Console.WriteLine("4.search items");
                Console.WriteLine("5.print");
                Console.WriteLine("6.exit");
                userInput = parseinput();
                UserOptions(userInput, programList);
                Console.WriteLine();
                if (userInput == 7)
                {
                    break;
                }
            }
        }
예제 #2
0
        static void UserOptions(int number, linkedList programList)
        {
            string newItems;

            switch (number)
            {
            case 1:
                Console.WriteLine("here is the first item in the list " + programList.GetFirst());
                break;

            case 2:
                Console.WriteLine("enter what you would like to be added to the list");
                newItems = getuserItem();
                programList.AddLast(newItems);
                Console.WriteLine(newItems + " was added");
                break;

            case 3:
                Console.WriteLine("enter the item you want to remove.");
                newItems = getuserItem();
                Console.WriteLine(programList.RemoveNode(newItems));
                break;

            case 4:
                Console.WriteLine("enter the item you want to search for.");
                newItems = getuserItem();
                Console.WriteLine(programList.SearchNodes(newItems));
                Console.WriteLine();
                break;

            case 5:
                Console.WriteLine("here is a list of all items that are in the list.");
                programList.PrintAllNodes();
                Console.WriteLine();
                break;

            case 6:
                Console.WriteLine();
                break;
            }
        }