public static void SearchingIndividual(string[,] FileHolder, int Size, int SortChoice, ref bool ExitCase)
        {
            //Class1.SendToHTML(FileHolder,Size);
            int  UserInput3 = -1;
            bool Menu3      = false;

            while (Menu3 == false)
            {
                //sorts all the files into a array FilePaths
                string[] FilePaths = Class1.SortArrayBubble();
                Console.Clear();
                Console.WriteLine("Below Shows all Avaliable file Titles:    ");
                //strips all the file path and leaves the name of file
                for (int i = 0; i < 11; i++)
                {
                    FilePaths[i] = Regex.Replace(Path.GetFileNameWithoutExtension(FilePaths[i]), @"[\d-]", string.Empty).Replace("_", "");
                    Console.WriteLine("{0}      :     {1}", i, FilePaths[i]);
                }
                Console.WriteLine("Please Enter the number for the file you wish to search:     ");
                try
                {   //User Input checked
                    UserInput3 = Convert.ToInt16(Console.ReadLine());
                    bool Menu4 = false;
                    while (Menu4 == false)
                    {
                        string UserInput4;
                        Console.WriteLine("Please Enter the Data you want to search for: (enure When you enter a decimal you make it three decimal places)    ");
                        try
                        {   //User Input checked
                            UserInput4 = Console.ReadLine();



                            if (SortChoice == 1)
                            {
                                //changes the input into a int using chnage to int method
                                string[,] TempChoice = new string[1, 1];
                                TempChoice[0, 0]     = UserInput4;
                                Class1.ChangeMonthsToInt(ref TempChoice, 1, 0);
                                UserInput4 = TempChoice[0, 0];
                                BinarySearchClass.BinarySearch(FileHolder, UserInput4, UserInput3, -1, -1, Size); //binary search
                            }
                            else if (SortChoice == 2)
                            {
                                LinearSearch.SearchLinear(FileHolder, UserInput4, UserInput3, Size); //linear search
                            }

                            bool Menu5 = false;
                            while (Menu5 == false)
                            {
                                Console.WriteLine("Please Enter y/n if you want to search again: ");
                                string UserInput5;
                                try
                                {                                               //User Input checked
                                    UserInput5 = Console.ReadLine();
                                    if (UserInput5 == "y" || UserInput5 == "Y") //checks to see if its yes
                                    {
                                        Menu5 = true;
                                        Menu4 = true;
                                    }
                                    else
                                    {
                                        Menu5    = true;
                                        Menu4    = true;
                                        Menu3    = true;
                                        ExitCase = true;
                                    }
                                }
                                catch (System.FormatException e) //Exception Handling
                                {
                                    Console.Clear();
                                    Console.WriteLine("Exception caught: {0}", e);
                                    Console.WriteLine();
                                }
                            }
                        }
                        catch (System.FormatException e) //Exception Handling
                        {
                            Console.Clear();
                            Console.WriteLine("Exception caught: {0}", e);
                            Console.WriteLine();
                        }
                    }
                }
                catch (System.FormatException e) //Exception Handling
                {
                    Console.Clear();
                    Console.WriteLine("Exception caught: {0}", e);
                    Console.WriteLine();
                }
            }
        }
示例#2
0
        //the search method for months
        public static void SearchMonth(string[,] FileHolder1, int Size, int Sortchoice)
        {
            bool TF = false;

            while (TF == false)
            {
                int NoMonth = 0;
                int count   = 0;
                Console.Clear();
                //asks the user to search one of the following months
                Console.WriteLine("Please Enter one of the following:   ");
                Console.WriteLine("");
                Console.WriteLine("1:   January ");
                Console.WriteLine("2:   February ");
                Console.WriteLine("3:   March ");
                Console.WriteLine("4:   April ");
                Console.WriteLine("5:   May ");
                Console.WriteLine("6:   June ");
                Console.WriteLine("7:   July ");
                Console.WriteLine("8:   August ");
                Console.WriteLine("9:   September ");
                Console.WriteLine("10:  October ");
                Console.WriteLine("11:  November ");
                Console.WriteLine("12:  December ");
                Console.WriteLine("");
                try
                {   //checks the users input
                    string MonthChose = Console.ReadLine();



                    if (Sortchoice == 1)                                                        //binary search
                    {
                        BinarySearchClass.BinarySearch(FileHolder1, MonthChose, 1, 0, 0, Size); //binary search method
                    }
                    else if (Sortchoice == 2)                                                   //linear search
                    {
                        LinearSearch.SearchLinear(FileHolder1, MonthChose, 1, Size);            //linear search method
                    }
                    bool TF2 = false;
                    while (TF2 == false)
                    {
                        Console.WriteLine("Would you like to sort another file? Enter Y/N     ");
                        string UserExitInput;
                        try
                        {
                            //checks the users input
                            UserExitInput = Console.ReadLine();
                            if (UserExitInput == "y" || UserExitInput == "Y") //checks if yes was entered
                            {
                                TF = false;
                            }
                            else
                            {
                                TF = true;
                            }
                        }
                        catch (System.FormatException e)
                        {
                            Console.WriteLine("Exception caught: {0}", e);
                            Console.WriteLine();
                        }
                        TF2 = true;
                    }
                }
                catch (System.FormatException e)
                {
                    Console.Clear();
                    Console.WriteLine("Exception caught: {0}", e);
                    Console.WriteLine();
                }
            }
        }