Ejemplo n.º 1
0
        public ICityResult Search(string searchString)
        {
            CitiesReturn ret = new CitiesReturn();

            foreach (string city in Cities)
            {
                bool bCityFound = true;
                for (int i = 0; i < searchString.Count(); i++)
                {
                    if (city[i] != searchString[i])
                    {
                        bCityFound = false;
                        break;
                    }
                }

                if (bCityFound)
                {
                    ret.addCity(city);
                    try
                    {
                        ret.addNextLetter("" + city[searchString.Length]);
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Init();

            Console.WriteLine("Insert Search Text Here");

            while (true)
            {
                string searchstr = Console.ReadLine().ToUpper();


                CitiesReturn results = (CitiesReturn)se.Search(searchstr);

                ICollection <string> resultLetters = results.NextLetters;
                ICollection <string> resultCities  = results.NextCities;



                foreach (string res in resultCities)
                {
                    Console.WriteLine(res);
                }


                foreach (string res in resultLetters)
                {
                    Console.WriteLine(res);
                }
            }
        }