Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating an address book...

 
Dan Silva
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm starting to create an address book, but am not aware of how to create a 'Search' field, like a normal gui address book. I am thinking that I should just check the first letter of the last name (which I'm not sure how to do either) and then just put each address in that particular unit (i.e. the Dan Silva would be in the 'S' class, and so on). If anyone can point me in the right direction for these, that would be great.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest search might require exact matches, just a String equals

String has some methods that might make things more fun. You might try

to find "il" in "Silva"

Probably next up the complexity ladder is regular expressions. If you've never used them, this might be a good excuse to learn. See the JavaDoc for Pattern and Google for "Sun tutorial regular expressions" to find more how-to.

For a journey into some pretty cool objects and algorithms, a Ternary Search Tree is a great way to do "autocomplete" things, so typing "S" might suggest "Silva" and "Smith" and "Si" would narrow down to just "Silva".

Think about doing all your compares on lower-cased strings to help your chances.

Any of those match your current skills & comfort?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic