コード例 #1
0
        public void Search_WithSearchString_ZE()
        {
            string searchText = "ZE";

            var expectedCities = new HashSet <string>
            {
            };

            var expectedLetters = new HashSet <string>
            {
            };

            CityFinder  finder     = new CityFinder();
            ICityResult cityResult = finder.Search(searchText);

            Assert.AreEqual(expectedCities.Count, cityResult.NextCities.Count);
            for (var i = 0; i < expectedCities.Count; i++)
            {
                Assert.AreEqual(expectedCities.Contains(searchText), cityResult.NextCities.Contains(searchText));
            }
            Assert.AreEqual(expectedLetters.Count, cityResult.NextLetters.Count);
            for (var i = 0; i < expectedLetters.Count; i++)
            {
                Assert.AreEqual(expectedLetters.Contains(searchText), cityResult.NextLetters.Contains(searchText));
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please Insert Search Term...");

            string searchTerm = Console.ReadLine();

            ICityRepository cityRepo   = new CityRepository();
            ICityFinder     cityFinder = new CityFinder(cityRepo);

            ICityResult cityResult = cityFinder.Search(searchTerm);

            int cityCount      = cityResult.NextCities.Count;
            int characterCount = cityResult.NextLetters.Count;

            Console.WriteLine($"Given Search Term {searchTerm}");
            Console.WriteLine($"Found {cityCount} Cities.");
            if (cityCount > 0)
            {
                foreach (string city in cityResult.NextCities)
                {
                    Console.WriteLine($"{city}");
                }
            }
            ;
            Console.WriteLine();
            Console.WriteLine($"Found {characterCount} Characters.");
            if (characterCount > 0)
            {
                foreach (string letter in cityResult.NextLetters)
                {
                    Console.WriteLine($"{letter}");
                }
            }
            Console.WriteLine("Finished Search.");
        }
コード例 #3
0
        public void SearchTest()
        {
            APIKey      apiKey  = new APIKey("AIzaSyC3evyffluu_gsQxMJq0ljpCrsFdfldLoM"); //TODO Use using here for efficiency
            CityFinder  finder  = new CityFinder(apiKey);
            ICityResult results = (CityResult)finder.Search("mid");

            ICollection <string> nextLetters = new List <string>();
            ICollection <string> nextCities  = new List <string>();

            nextCities.Add("Midland");
            nextCities.Add("Midrand");
            nextCities.Add("Midlothian");
            nextCities.Add("Middlesbrough");
            nextCities.Add("Middletown");

            nextLetters.Add("l");
            nextLetters.Add("r");
            nextLetters.Add("l");
            nextLetters.Add("d");
            nextLetters.Add("d");

            ICityResult testResults = new CityResult(nextLetters, nextCities);

            for (int i = 0; i > nextCities.Count; i++)
            {
                Assert.AreEqual(testResults.NextCities.ElementAt(i), results.NextCities.ElementAt(i));
            }

            for (int i = 0; i > nextLetters.Count; i++)
            {
                Assert.AreEqual(testResults.NextLetters.ElementAt(i), results.NextLetters.ElementAt(i));
            }
        }
コード例 #4
0
        private bool ReturnedExpectedNextCities(ICityResult result)
        {
            bool firstCity  = false;
            bool secondCity = false;
            bool thirdCity  = false;

            foreach (string nextCity in result.NextCities)
            {
                if (nextCity.Equals("darlington"))
                {
                    firstCity = true;
                }

                if (nextCity.Equals("darlington county"))
                {
                    secondCity = true;
                }

                if (nextCity.Equals("darlington point"))
                {
                    thirdCity = true;
                }
            }

            if (firstCity && secondCity && thirdCity)
            {
                return(true);
            }

            return(false);
        }
コード例 #5
0
        private bool ReturnedExpectedNextCharacters(ICityResult result)
        {
            bool containsE = false;
            bool containsH = false;
            bool containsT = false;

            foreach (string nextCharacter in result.NextLetters)
            {
                if (nextCharacter.Equals("e"))
                {
                    containsE = true;
                }

                if (nextCharacter.Equals("h"))
                {
                    containsH = true;
                }

                if (nextCharacter.Equals("t"))
                {
                    containsT = true;
                }
            }

            if (containsT && containsH && containsE)
            {
                return(true);
            }

            return(false);
        }
コード例 #6
0
        public ActionResult SearchCity(string searchString)
        {
            CityFinder  cf   = new CityFinder();
            ICityResult cres = cf.Search(searchString);

            return(View(cres.NextCities.ToList().ToString()));
        }
コード例 #7
0
        private bool ReturnedResults(ICityResult result)
        {
            if (result.NextCities.Count == 0)
            {
                return(false);
            }

            return(true);
        }
コード例 #8
0
        static void Search(string searchString)
        {
            Stopwatch   timePerParse = Stopwatch.StartNew();
            ICityFinder cityFinder   = new CityFinder();
            ICityResult cityResult   = cityFinder.Search(searchString);

            timePerParse.Stop();

            Console.WriteLine($"Next Cities: {cityResult.NextCities.Count}.");
            Console.WriteLine($"Next Letters: {cityResult.NextLetters.Count}.");
            Console.WriteLine($"Time (ms): {timePerParse.Elapsed.Milliseconds}.");
        }
コード例 #9
0
        public void GivenFullNames_CityFinder_CompletesSuccessfulWithNoIndexErrors(
            string searchTerm,
            List <string> countries,
            ICityResult expectedCityResult)
        {
            CountryRepoistoryMock
            .Setup(x => x.GetCities())
            .Returns(countries);

            ICityResult result = sut.Search(searchTerm);

            Assert.AreEqual(JsonConvert.SerializeObject(expectedCityResult), JsonConvert.SerializeObject(result));
        }
コード例 #10
0
        private string AvailableNextCharactersMessage(ICityResult result)
        {
            string message = "The following next characters are available:";

            foreach (string letter in result.NextLetters)
            {
                message = $"{message} {letter},";
            }

            message = message.TrimEnd(',');

            return(message);
        }
コード例 #11
0
        public void Main()
        {
            Trie trie = new Trie();

            trie.Init();

            const string sanitizedSearchTerm = "darlingt";

            ICityResult result = trie.Search(sanitizedSearchTerm);

            Assert.AreEqual(ReturnedResults(result), true);
            Assert.AreEqual(ReturnedExpectedNextCities(result), true);
        }
コード例 #12
0
        private string AvailableNextCitiesMessage(ICityResult result)
        {
            string message = "The following cities are available:";

            foreach (string city in result.NextCities)
            {
                message = $"{message} {city},";
            }

            message = message.TrimEnd(',');

            return(message);
        }
コード例 #13
0
        public void GivenStringZE_CityFinder_FindsNoResults(
            string searchTerm,
            List <string> countries,
            ICityResult expectedCityResult)
        {
            CountryRepoistoryMock
            .Setup(x => x.GetCities())
            .Returns(countries);

            ICityResult result = sut.Search(searchTerm);

            Assert.AreEqual(JsonConvert.SerializeObject(expectedCityResult), JsonConvert.SerializeObject(result));
        }
コード例 #14
0
        public ActionResult Index(string searchString)
        {
            CityFinder  cf   = new CityFinder();
            ICityResult cres = cf.Search(searchString);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("PartialSearch", cres));
            }
            else
            {
                return(View(cres));
            }
        }
コード例 #15
0
        public void WithSearchStringBANGK_ShouldReturn_A_O(string searchString)
        {
            ICollection <string> expectedCities = new Collection <string>();

            ICollection <string> expectedLetters = new Collection <string> {
                "A",
                "O",
            };

            ICityResult expect = new CityResult(expectedCities, expectedLetters);

            ICityFinder cityFinder = new CityFinder();
            ICityResult actual     = cityFinder.Search(searchString);

            Assert.IsTrue(expect.NextLetters.SequenceEqual(actual.NextLetters));
        }
コード例 #16
0
        static void Main(string[] args)
        {
            CityFinder  cf   = new CityFinder();
            ICityResult cres = cf.Search("Bang");

            foreach (var item in cres.NextCities)
            {
                Console.WriteLine(item.ToString());
            }

            foreach (var item in cres.NextLetters)
            {
                Console.WriteLine(item.ToString());
            }

            Console.Read();
        }
コード例 #17
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            string query = textBox1.Text;

            listBox1.Items.Clear();
            listBox2.Items.Clear();

            ICityResult citySearch = cityFinder.Search(query);

            foreach (var letter in citySearch.NextLetters)
            {
                listBox2.Items.Add(letter);
            }
            foreach (var city in citySearch.NextCities)
            {
                listBox1.Items.Add(city);
            }
        }
コード例 #18
0
        public void ReadLoop()
        {
            string message;
            string searchterm;
            string sanitizedSearchTerm;

            Trie trie = new Trie();

            trie.Init();

            displayWelcomeMessage();

            while (true)
            {
                message             = "";
                searchterm          = Console.ReadLine();
                sanitizedSearchTerm = SanitizeInput(searchterm);

                ICityResult result = trie.Search(sanitizedSearchTerm);

                if (sanitizedSearchTerm == "exit")
                {
                    break;
                }
                else if (result.NextLetters.Count.Equals(0) && result.NextCities.Count.Equals(0))
                {
                    message = "Input does not bear resemblance to anything. Unable to suggest next characters or cities";
                }
                else
                {
                    if (result.CityFound)
                    {
                        message = sanitizedSearchTerm + " is a city\n";
                    }

                    message = message + AvailableNextCitiesMessage(result) + "\n" + AvailableNextCharactersMessage(result);
                }

                Console.WriteLine(" -- Start of results for '" + searchterm + "' --");
                Console.WriteLine(message);
                Console.WriteLine(" -- End of results for '" + searchterm + "' --");
            }
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: bhayward93/CitySearch
        static void Main(string[] args)
        {
            try
            {
                APIKey     apiKey = new APIKey("AIzaSyC3evyffluu_gsQxMJq0ljpCrsFdfldLoM"); //Provide an APIKey for the API
                CityFinder finder = new CityFinder(apiKey);                                //Instantiate a new CityFinder

                Console.Write("Welcome to CitySearch's example implementation.\n" +
                              "Please enter a search string to continue:\n");

                while ("pigs" != "fly")
                {
                    string      searchString = Console.ReadLine();                      //Await user input.
                    ICityResult results      = (CityResult)finder.Search(searchString); //Search the API using the finder, and a search string parameter

                    Console.Write("--------------------\n" +
                                  "Predicted City Names:\n\n");

                    foreach (string city in results.NextCities)
                    {   //Itterate through the cities in the results and write them to console
                        Console.Write("City Name:\t" + city + "\n");
                    }

                    Console.Write("--------------------\n" +
                                  "Predicted Next Letters:\n\n");
                    foreach (string letter in results.NextLetters)
                    {   //Same as as above, but for the next letters.
                        Console.Write("Next Letter:\t" + letter + "\n");
                    }
                    Console.Write("--------------------\n");
                    Console.Write("Enter Another Search :\n");
                }
            }
            catch (Exception e)
            {
                Debug.Write("Program quit unexpectedly: \n", e.Source);
            }
        }
コード例 #20
0
        static void Main(string[] args)
        {
            // Create CityFinder and store the example cities
            cityFinder = new CityFinder();
            cities     = new List <string>(new string[] { "Abingdon", "Accrington", "Acton", "Adlington", "Alcester", "Aldeburgh", "Aldershot", "Aldridge", "Alford", "Alfreton", "Alnwick", "Alsager", "Alston", "Alton", "Altrincham", "Amble", "Amersham", "Amesbury", "Ampthill", "Andover", "Appleby-in-Westmorland", "Arundel", "Ashbourne", "Ashburton", "Ashby-de-la-Zouch", "Ashford", "Ashington", "Ashton-in-Makerfield", "Ashton-under-Lyne", "Askern", "Aspatria", "Atherstone", "Attleborough", "Axbridge", "Axminster", "Aylesbury", "Aylsha", "Bacup", "Bakewell", "Baldock", "Banbury", "Barking", "Barnard Castle", "Barnet", "Barnoldswick", "Barnsley", "Barnstaple", "Barnt Green", "Barrow-in-Furness", "Barton-upon-Humber", "Barton-le-Clay", "Basildon", "Basingstoke", "Bath", "Batley", "Battle", "Bawtry", "Beaconsfield", "Beaminster", "Bebington", "Beccles", "Bedale", "Bedford", "Bedlington", "Bedworth", "Beeston", "Belper", "Bentham", "Berkhamsted", "Berwick-upon-Tweed", "Beverley", "Bewdley", "Bexhill-on-Sea", "Bicester", "Biddulph", "Bideford", "Biggleswade", "Billericay", "Bilston", "Bingham", "Birmingham", "Bishop Auckland", "Bishop's Castle", "Bishop's Stortford", "Bishop's Waltham", "Blackburn", "Blackpool", "Blandford Forum", "Bletchley", "Blyth", "Bodmin", "Bognor Regis", "Bollington", "Bolsover", "Bolton", "Bordon", "Borehamwood", "Boston", "Bottesford", "Bourne", "Bournemouth", "Brackley", "Bracknell", "Bradford", "Bradford-on-Avon", "Bradley Stoke", "Bradninch", "Braintree", "Brentford", "Brentwood", "Bridgnorth", "Bridgwater", "Bridlington", "Bridport", "Brierley Hill", "Brigg", "Brighouse", "Brightlingsea", "Brighton", "Bristol", "Brixham", "Broadstairs", "Bromley", "Bromsgrove", "Bromyard", "Brownhills", "Buckfastleigh", "Buckingham", "Bude", "Budleigh Salterton", "Bungay", "Buntingford", "Burford", "Burgess Hill", "Burnham-on-Crouch", "Burnham-on-Sea", "Burnley", "Burntwood", "Burton Latimer", "Burton-upon-Trent", "Bury", "Bury St Edmunds", "Buxton", "Blackbur", "Caistor", "Calne", "Camberley", "Camborne", "Cambridge", "Camelford", "Cannock", "Canterbury", "Carlisle", "Carnforth", "Carterton", "Castle Cary", "Castleford", "Chadderton", "Chagford", "Chard", "Charlbury", "Chatham", "Chatteris", "Chelmsford", "Cheltenham", "Chesham", "Cheshunt", "Chester", "Chesterfield", "Chester-le-Street", "Chichester", "Chippenham", "Chipping Campden", "Chipping Norton", "Chipping Ongar", "Chipping Sodbury", "Chorley", "Christchurch", "Church Stretton", "Cinderford", "Cirencester", "Clacton-on-Sea", "Cleckheaton", "Cleethorpes", "Clevedon", "Cleveleys", "Clitheroe", "Clun", "Coalville", "Cockermouth", "Coggeshall", "Colchester", "Coleford", "Colne", "Congleton", "Conisbrough", "Corbridge", "Corby", "Cotgrave", "Coventry", "Cowes", "Cramlington", "Cranfield", "Crawley", "Crayford", "Crediton", "Crewe", "Crewkerne", "Cromer", "Crowborough", "Crowle", "Crowthorne", "Croydon", "Cuckfield", "Cullompton", "connor town", "Dagenham", "Dalton in Furness", "Darley Dale", "Darlington", "Dartford", "Dartmouth", "Darwen", "Daventry", "Dawlish", "Deal", "Denholme", "Denton", "Derby", "Dereham", "Desborough", "Devizes", "Dewsbury", "Didcot", "Dinnington", "Diss", "Doncaster", "Dorchester", "Dorking", "Dover", "Downham Market", "Driffield", "Dronfield", "Droitwich Spa", "Droylsden", "Dudley", "Dukinfield", "Dunstable", "Durham", "Dursley", "Ealing", "Earley", "Easingwold", "Eastbourne", "East Grinstead", "East Ham", "Eastleigh", "Eastwood", "Edenbridge", "Egham", "Ellesmere", "Ellesmere Port", "Ely", "Enfield", "Epping", "Epsom", "Epworth", "Erith", "Esher", "Eton", "Evesham", "Exeter", "Exmouth", "Eye", "Failsworth", "Fairford", "Fakenham", "Falmouth", "Fareham", "Faringdon", "Farnborough", "Farnham", "Farnworth", "Faversham", "Featherstone", "Felixstowe", "Fenny Stratford", "Ferndown", "Ferryhill", "Filey", "Filton", "Fleet", "Fleetwood", "Flitwick", "Folkestone", "Fordingbridge", "Fordwich", "Fowey", "Framlingham", "Frinton-on-Sea", "Frodsham", "Frome", "Foxley", "Gainsborough", "Gateshead", "Gillingham", "Gillingham", "Glastonbury", "Glossop", "Gloucester", "Godalming", "Godmanchester", "Goole", "Gosport", "Grange-over-Sands", "Grantham", "Gravesend", "Grays", "Great Dunmow", "Great Torrington", "Great Yarmouth", "Grimsby", "Guildford", "Guisborough", "Hackney", "Hadleigh", "Hailsham", "Halesworth", "Halewood", "Halifax", "Halstead", "Haltwhistle", "Harlow", "Harpenden", "Harrogate", "Harrow", "Hartlepool", "Harwich", "Haslemere", "Hastings", "Hatfield", "Havant", "Haverhill", "Hawley", "Hayle", "Haywards Heath", "Heanor", "Heathfield", "Hebden Bridge", "Hedon", "Helston", "Hemel Hempstead", "Hemsworth", "Henley-in-Arden", "Henley-on-Thames", "Hendon", "Hereford", "Herne Bay", "Hertford", "Hessle", "Heswall", "Hetton-le-Hole", "Heywood", "Hexham", "Higham Ferrers", "Highworth", "High Wycombe", "Hinckley", "Hitchin", "Hoddesdon", "Holmfirth", "Holsworthy", "Honiton", "Horley", "Horncastle", "Hornsea", "Horsham", "Horwich", "Houghton-le-Spring", "Hounslow", "Hoylake", "Hove", "Hucknall", "Huddersfield", "Hugh Town", "Hull", "Hungerford", "Hunstanton", "Huntingdon", "Hyde", "Hythe", "Ilchester", "Ilford", "Ilfracombe", "Ilkeston", "Ilkley", "Ilminster", "Ipswich", "Irthlingborough", "Ivybridge", "Jarrow", "Keighley", "Kempston", "Kendal", "Kenilworth", "Kesgrave", "Keswick", "Kettering", "Keynsham", "Kidderminster", "Kidsgrove", "Killingworth", "Kimberley", "Kingsbridge", "King's Lynn", "Kingston-upon-Hull", "Kingston upon Thames", "Kington", "Kirkby", "Kirkby-in-Ashfield", "Kirkby Lonsdale", "Kirkham", "Knaresborough", "Knottingley", "Knutsford", "Kingsteignton", "Lancaster", "Launceston", "Leatherhead", "Leamington Spa", "Lechlade", "Ledbury", "Leeds", "Leek", "Leicester", "Leigh", "Leighton Buzzard", "Leiston", "Leominster", "Letchworth", "Lewes", "Lewisham", "Leyland", "Leyton", "Lichfield", "Lincoln", "Liskeard", "Littlehampton", "Liverpool", "Lizard", "London", "London", "Long Eaton", "Longridge", "Looe", "Lostwithiel", "Loughborough", "Loughton", "Louth", "Lowestoft", "Ludlow", "Luton", "Lutterworth", "Lydd", "Lydney", "Lyme Regis", "Lymington", "Lynton", "Lytchett Minster", "Lytham St Annes", "Lofthouse", "Mablethorpe", "Macclesfield", "Maghull", "Maidenhead", "Maidstone", "Maldon", "Malmesbury", "Maltby", "Malton", "Malvern", "Manchester", "Manningtree", "Mansfield", "March", "Margate", "Market Deeping", "Market Drayton", "Market Harborough", "Market Rasen", "Market Weighton", "Marlborough", "Marlow", "Maryport", "Marston Moretaine", "Matlock", "Melksham", "Melton Mowbray", "Mexborough", "Middleham", "Middlesbrough", "Middleton", "Middlewich", "Midhurst", "Midsomer Norton", "Milton Keynes", "Minehead", "Morecambe", "Moretonhampstead", "Moreton-in-Marsh", "Morley", "Morpeth", "Much Wenlock", "Nailsea", "Nailsworth", "Nantwich", "Needham Market", "Nelson", "Neston", "Newark-on-Trent", "Newbiggin-by-the-Sea", "Newbury", "Newcastle-under-Lyme", "Newcastle upon Tyne", "Newent", "Newhaven", "Newmarket", "New Mills", "New Milton", "Newport", "Newport", "Shropshire", "Newport Pagnell", "Newquay", "New Romney", "Newton Abbot", "Newton Aycliffe", "Newton-le-Willows", "Normanton", "Northallerton", "Northam", "Northampton", "North Walsham", "Northwich", "Norton Radstock", "Norwich", "Nottingham", "Nuneaton", "Oakham", "Okehampton", "Oldbury", "Oldham", "Ollerton", "Olney", "Ormskirk", "Orpington", "Ossett", "Oswestry", "Otley", "Ottery St Mary", "Oundle", "Oxford", "Outwood", "Paddock Wood", "Padstow", "Paignton", "Painswick", "Peacehaven", "Penistone", "Penrith", "Penryn", "Penzance", "Pershore", "Peterborough", "Peterlee", "Petersfield", "Petworth", "Pickering", "Plymouth", "Pocklington", "Pontefract", "Polegate", "Poltimore", "Poole", "Portishead", "Portland", "Portslade", "Portsmouth", "Potters Bar", "Potton", "Poulton-le-Fylde", "Prescot", "Preston", "Princes Risborough", "Prudhoe", "Pudsey", "Queenborough", "Quintrell Downs", "Ramsgate", "Raunds", "Rayleigh", "Reading", "Redcar", "Redditch", "Redhill", "Redruth", "Reigate", "Retford", "Richmond", "Richmond-upon-Thames", "Rickmansworth", "Ringwood", "Ripley", "Ripon", "Rochdale", "Rochester", "Rochford", "Romford", "Romsey", "Ross-on-Wye", "Rothbury", "Rotherham", "Rothwell", "Rowley Regis", "Royston", "Rugby", "Rugeley", "Runcorn", "Rushden", "Rutland", "Ryde", "Rye", "Saffron Walden", "Selby", "St Albans", "St Asaph", "St Austell", "St Blazey", "St Columb Major", "St Helens", "St Ives", "Cambridgeshire", "St Ives", "Cornwall", "St Neots", "Salcombe", "Sale", "Salford", "Salisbury", "Saltash", "Saltburn-by-the-Sea", "Sandbach", "Sandhurst", "Sandown", "Sandwich", "Sandy", "Sawbridgeworth", "Saxmundham", "Scarborough", "Scunthorpe", "Seaford", "Seaton", "Sedgefield", "Selby", "Selsey", "Settle", "Sevenoaks", "Shaftesbury", "Shanklin", "Sheerness", "Sheffield", "Shepshed", "Shepton Mallet", "Sherborne", "Sheringham", "Shildon", "Shipston-on-Stour", "Shoreham-by-Sea", "Shrewsbury", "Sidcup", "Sidmouth", "Sittingbourne", "Skegness", "Skelmersdale", "Skipton", "Sleaford", "Slough", "Smethwick", "Snodland", "Soham", "Solihull", "Somerton", "Southall", "Southam", "Southampton", "Southborough", "Southend-on-Sea", "South Molton", "Southport", "Southsea", "South Shields", "Southwell", "Southwold", "South Woodham Ferrers", "Spalding", "Spennymoor", "Spilsby", "Stafford", "Staines", "Stainforth", "Stalybridge", "Stamford", "Stanley", "Stapleford", "Staunton", "Staveley", "Stevenage", "Stockport", "Stocksbridge", "Stockton-on-Tees", "Stoke-on-Trent", "Stone", "Stony Stratford", "Stotfold", "Stourbridge", "Stourport-on-Severn", "Stowmarket", "Stow-on-the-Wold", "Stratford-upon-Avon", "Streatham", "Street", "Strood", "Stroud", "Sudbury", "Sunderland", "Sutton", "Sutton Coldfield", "Sutton-in-Ashfield", "Swadlincote", "Swaffham", "Swanage", "Swanley", "Swindon", "Swinton", "Tadcaster", "Tadley", "Tamworth", "Taunton", "Tavistock", "Teignmouth", "Telford", "Tenbury Wells", "Tenterden", "Tetbury", "Tewkesbury", "Thame", "Thatcham", "Thaxted", "Thetford", "Thirsk", "Thong", "Thornaby", "Thornbury", "Thorne", "Tickhill", "Tilbury", "Tipton", "Tiverton", "Todmorden", "Tonbridge", "Torpoint", "Torquay", "Totnes", "Tottenham", "Totton", "Towcester", "Tring", "Trowbridge", "Truro", "Tunbridge Wells", "Twickenham", "Uckfield", "Ulverston", "Uppingham", "Upton-upon-Severn", "Uttoxeter", "Uxbridge", "Ventnor", "Verwood", "Wadebridge", "Wadhurst", "Wakefield", "Wallasey", "Wallingford", "Walmer", "Walsall", "Waltham Abbey", "Waltham Cross", "Walthamstow", "Walton-on-Thames", "Walton-on-the-Naze", "Wandsworth", "Wantage", "Ware", "Wareham", "Warminster", "Warwick", "Washington", "Watchet", "Watford", "Wath-upon-Dearne", "Watton", "Wednesbury", "Wellingborough", "Wellington", "Wells", "Wells-next-the-Sea", "Welwyn Garden City", "Wem", "Wendover", "West Bromwich", "Westbury", "Westerham", "West Ham", "Westhoughton", "West Kirby", "West Mersea", "Westminster", "Weston-super-Mare", "Westward Ho!", "Wetherby", "Weybridge", "Weymouth", "Whaley Bridge", "Whiston", "Whitby", "Whitchurch", "Whitehaven", "Whitley Bay", "Whitnash", "Whitstable", "Whitworth", "Wickford", "Widnes", "Wigan", "Wigston", "Willenhall", "Wimbledon", "Wimborne Minster", "Wincanton", "Winchcombe", "Winchelsea", "Winchester", "Windermere", "Winsford", "Winslow", "Wisbech", "Witham", "Withernsea", "Witney", "Wivenhoe", "Woburn", "Woking", "Wokingham", "Wolverhampton", "Wombwell", "Woodbridge", "Woodstock", "Wooler", "Woolwich", "Wootton Bassett", "Worcester", "Workington", "Worksop", "Worthing", "Wotton-under-Edge", "Wymondham" });

            foreach (string city in cities)
            {
                cityFinder.Add(city);
            }

            // Start main loop of searching for suggestions and valid next letters.
            string search = "";

            while (true)
            {
                ICityResult result = cityFinder.Search(search);

                DisplayNextCities(result.NextCities);
                DisplayLetters(result.NextLetters);
                search = GetUserInput(result.NextLetters, search);
            }
        }
コード例 #21
0
 public CityFinderService(ICityResult cityResult)
 {
     // initialize source data
     sourceData      = new HashSet <string>(new CityNames().cities);
     this.cityResult = cityResult;
 }