Searching on ArrayList
Hi everyone, I am trying to do a search in an arraylist of objects books from a class called Catalogue. The book class has a string description and a borrower number (which is set up to 0, meaning not on loan).
I should be able to borrow a book once I've done a search, and this search has to found only ONE book.
there it is the code that I have got so far.. could somebody help me?
public void Search(String entry, int borrower)
{
for(Book book : books){
if (book.getDescription().equals(entry) || book.getDescription().contains(entry)){
searchNumber++;
System.out.println(searchNumber + " " + book.getDescription()); }
if (book.getBorrowerNumber() == 0 && book.getDescription().equals("")){
searchNumber++;
System.out.println(searchNumber + " " + book.getDescription());}
if (book.getBorrowerNumber() == borrower && book.getBorrowerNumber() != 0){
searchNumber++;
System.out.println(searchNumber + " " + book.getDescription());}
}
if(searchNumber ==1 ){
Book.setBorrowerNumber(int yourID());
if(borrower==0){
System.out.print("please enter your ID number");}
}
else{
System.out.println("search Better");}
}

