Hmmm... like the others indicated, there is very little to go on with this question. I will do my best and improvise.
If you are using an OR mapping tool (like Hibernate, JDO or CMP) you could get the Book object by its id, update its availability, and save the book. For example, the Book class might look something like:
public class Book {
private boolean available = false;
private String title;
/** add other attributes, a constructor, and getters and setters**/
public void checkIn(){
this.available = true;
}
}
You would then have a service class that might look something like this:
public class BookService{
private BookDao dao;
public void setBookDao(BookDao dao){
this.dao = dao;
}
public void checkInBook(long bookId){
Book book = dao.findBookById(bookId);
book.checkIn();
dao.save(book);
}
}
Hope that helps. :^)
2006-11-01 12:08:37
·
answer #1
·
answered by Liggy 2
·
0⤊
0⤋
I wrote something like this for a C++ class. I kept two separate data lists. One for the people and one for the books. I structured the variables so that there was a pointer to a book within a person's information and a pointer to a person within a book's information. When a book was returned, I just reset these pointers to null.
2006-11-01 06:24:18
·
answer #2
·
answered by iuneedscoachknight 4
·
0⤊
0⤋
It's sort of hard to answer your question without more info.
2006-11-01 06:07:32
·
answer #3
·
answered by Glen 2
·
0⤊
0⤋
WAY too little info on this one
2006-11-01 06:08:41
·
answer #4
·
answered by Anonymous
·
1⤊
0⤋