English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

The teacher gave as the methods which the interface should define. In order to return a list of books for a given author i have to use the method:

List lookupBook (String author)

Can someone help me write the code for this method or share any relevant information pls?! I have never seen methods of this sort (containing keyword lookup) I am using a vector list to store books.

2007-12-20 06:02:41 · 2 answers · asked by buhaar 2 in Computers & Internet Programming & Design

2 answers

lookupBook(String author) appears to be a method that you will have to write. The example I show below uses some other class to actually get the books but you could just as easily move your logic into this method. I am not entirely sure what your source is for the book information. If you mean that you have a vector of the books predefined, then you really need to look at using the Vector.contains(Object elem) method to find and transfer that "Book" to a temporary Vector (or List) with the results that you would then return.

public class BookUtil {

public List lookupBook(String author) {
// Not sure how you are building your Vector so using a fictitious object that returns a vector of books.
Vector bookVector = BookFinder.byAuthor(author);
// You can just return the vector here as Vector implements the List object
return bookVector;
}
}

2007-12-20 06:47:00 · answer #1 · answered by Jim Maryland 7 · 0 0

Use Eclipse IDE to run classes. i % to propose it as a results of fact it helps you concentration at this technique layout extremely than on the syntax (you learn syntax as you software). JDK is the place you write the classes(which contain Eclipse). You assemble it through making constructive you have JRE (java runtime atmosphere)

2016-12-11 10:12:55 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers