Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

address book model

 
Mark Holohan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a relative newbie to Java, I'd like to practice creating an simple application where a phone number is entered as input by the user and a corresponding address is returned.
What should my approach be? Do I have to use a separate file for to contain the addresses? Or can I set up an array list or vector instead and add each address "on the fly"? Any tips on the GUI and listeners involved? My most important requirement is that the list of addresses doesn't get erased each time I turn off the computer (I think the term is Serializable?)

Thanks,
MH
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your addresses can also be in a datbase. You can use the phone number as the key to lookup an address. If it's web based, you can have your client enter the phone number through JSP/HTML and then have a servlet in the backend that does the Db lookup and returns the result to the JSP to display. OTOH, you can just have the servlet display the results directly (the servlet will format and output HTML)

Bosun
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would start out by putting the address information (hardcoded) in a Vector or better yet an ArrayList as a set of Address objects. Once you have the mechanism of retrieving the information from the ArrayList and displaying it you can go back and add in the GUI input or I/O neccessary to read the data in from a source and loading the ArrayList.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into HashMap you can use the phone number as the key to retrieve your adress object. That way you don't need to write your own lookup stategy if you don't use a DB.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic