If you must use Java... I recommend you encapsulate the book data inside a Book class. Your library can store the books in a HashMap to provide quick access and scale-ability. In fact, you could use several HashMaps together to allow you to reach the book according to any one of its features (e.g. author or genre).
The Book class might look like this:
class Book{
HashMap<String, String> features;
public Book(){
this.features= new HashMap<String,String>();
}
public HashMap<String, String> getFeatures() {
return features;
}
public String addFeature(String key,String value){
return features.put(key, value);
}
public void addFeatures(HashMap<String, String> newFeatures){
this.features.putAll(newFeatures);
}
}
Your Library class could use a HashMap of HashMaps:
HashMap<String,HashMap<String,Book>> library;
So, to access a book, you call
public Book getBook(String featureType,String key){
return library.get(featureType).get(key);
}
The featureType string specifies whether you're looking up a book by author, genre, description, etc. The key is the specific author's name. For example, to get a book by Bob Smith, you would use getBook("author","Bob Smith");.
You can add books to the library as follows:
public void addBookToLibrary(Book book){
HashMap<String,String> bookFeatures = book.getFeatures();
for(String featureType : bookFeatures.keySet()){
HashMap<String,Book> libraryFeatureMap = library.get(featureType);
libraryFeatureMap.put(bookFeatures.get(featureType), book);
}
}