Exemple #1
0
        public static void menu()
        {
            char        c;
            string      name;
            StringArray myArray = new StringArray();

            Console.WriteLine("Choose from the following options:" + "\n" + "\n" +
                              "(I)nsert" + "\n" + "(D)elete" + "\n" + "Display (A)ll" + "\n" + "(Q)uit");
            c = Console.ReadLine()[0];
            c = Char.ToUpper(c);
            while (c != 'Q')
            {
                while (c != 'N')
                {
                    if (c == 'I')
                    {
                        while (c != 'N')
                        {
                            Console.Clear();
                            Console.Write("Enter a name: ");
                            name = Console.ReadLine();
                            myArray.insertion(name);
                            Console.Write("Continue? (Y)/(N)");
                            c = Console.ReadLine()[0];
                            c = Char.ToUpper(c);
                        }
                    }
                    else if (c == 'D')
                    {
                        int search;
                        Console.Clear();
                        Console.WriteLine("Enter name for deletion: ");
                        name   = Console.ReadLine();
                        search = myArray.findString(name);
                        myArray.del(search);
                        c = 'N';
                    }
                    else if (c == 'A')
                    {
                        Console.Clear();
                        myArray.PrintArray();
                        Console.ReadLine();
                        c = 'N';
                    }
                }
                Console.Clear();
                Console.WriteLine("Choose from the following options:" + "\n" + "\n" +
                                  "(I)nsert" + "\n" + "(D)elete" + "\n" + "Display (A)ll" + "\n" + "(Q)uit");
                c = Console.ReadLine()[0];
                c = Char.ToUpper(c);
            }
        }
Exemple #2
0
        public static void demoStringSort()
        {
            string      cat;
            int         ndx;
            StringArray myArray = new StringArray();

            myArray.add("Tegan");
            myArray.add("Alystra");
            myArray.add("Brandon");
            myArray.add("Oliver");
            myArray.add("Casey");
            myArray.add("Midnight");
            myArray.add("Jeremiah");
            myArray.add("Maya");

            myArray.BubbleSort();
            myArray.PrintArray();
            cat = "Midnight";
            ndx = myArray.findString(cat);
            Console.WriteLine("{0} found at index: {1}", cat, ndx);
        }