5 Replies - 219 Views - Last Post: 02 November 2013 - 04:24 AM Rate Topic: -----

#1 cynthia2010  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 02-November 13

How to write a code that can browse the list of books

Posted 02 November 2013 - 02:36 AM

Hi,
Am a beginner in Java programming and would like assistance with java code that can browse the list of books,view a list of books,and view the status of books if borrowed or not.
Book findBook (String isbn) {
	int counter;
	Book tmp;
	String currentIsbn;
	
	counter = 0;
	
	for (counter = 0; counter < allBooks.size(); counter += 1) {
		tmp = allBooks.get(counter);
	
		currentIsbn = tmp.getISBN();
	
		if (currentIsbn.equals(isbn)) {
			return tmp;
  		}	
	}	
	return null;
}


Above is a code I've written to find the book.
Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: How to write a code that can browse the list of books

#2 ChrisNt  Icon User is online

  • cute bug

Reputation: 213
  • View blog
  • Posts: 653
  • Joined: 31-July 13

Re: How to write a code that can browse the list of books

Posted 02 November 2013 - 02:38 AM

So where is the problem?
Was This Post Helpful? 0
  • +
  • -

#3 cynthia2010  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 02-November 13

Re: How to write a code that can browse the list of books

Posted 02 November 2013 - 02:47 AM

From the code I posted, I would like it to include java code that can browse the list of books,view a list of books,and view the status of books if borrowed or not.

I am not sure how to go about it.
Was This Post Helpful? 0
  • +
  • -

#4 ChrisNt  Icon User is online

  • cute bug

Reputation: 213
  • View blog
  • Posts: 653
  • Joined: 31-July 13

Re: How to write a code that can browse the list of books

Posted 02 November 2013 - 02:58 AM

What you mean browse?
To view the list you just have to call method toString()(which you should override in your Contact class) in your loop ,
To view the status you have to call the method that returns the status of contact

This post has been edited by ChrisNt: 02 November 2013 - 03:00 AM

Was This Post Helpful? 0
  • +
  • -

#5 cynthia2010  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 02-November 13

Re: How to write a code that can browse the list of books

Posted 02 November 2013 - 03:02 AM

Its 'browse' please.

Would you mind showing me a sample code on how to do that if you don't mind?
Was This Post Helpful? 0
  • +
  • -

#6 ChrisNt  Icon User is online

  • cute bug

Reputation: 213
  • View blog
  • Posts: 653
  • Joined: 31-July 13

Re: How to write a code that can browse the list of books

Posted 02 November 2013 - 04:24 AM

Will print all details of all contacts in ArrayList
for (Contact c: list) {
     c.toString();
}


or you can just do
System.out.println(list);

This post has been edited by ChrisNt: 02 November 2013 - 04:30 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1