Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. // check out the book only if it is in the list of available
  2. // only if the person is a patron and the book is in the library and not currently checked out.
  3. // update the book in the library not the book being passed into the method.
  4. // update the due date for the book object
  5. // return true if the book is successfully checked out and false otherwise
  6. public boolean checkOut(Person p, Book b, String dueDate){
  7. // see if the person is in the name list
  8. if (!this.getPatrons().contains(p)){
  9. return false;
  10. }
  11.  
  12. // see if the book is in the library and not get checked out
  13. if (!this.getLibraryBooks().contains(b)){
  14. return false;
  15. }
  16.  
  17. if (dueDate.length() != 10){
  18. return false;
  19. }
  20.  
  21. // update the due date of the book in the arrayList
  22. // a for loop is needed to change the actual book in the person
  23. for (Book loopBook: this.l){
  24. // checks if the book
  25. if (loopBook.equals(b) && loopBook.isCheckedOut() == false){
  26. // sets the dues date, assigns it to the person
  27. loopBook.setDueDate(dueDate);
  28. p.addBook(loopBook);
  29.  
  30. // changes the ischecked out book
  31. loopBook.setCheckedOut(true);
  32. return true;
  33.  
  34.  
  35.  
  36. }
  37.  
  38. }
  39.  
  40.  
  41.  
  42. // return true or false
  43. // decrease the number of books in the library
  44.  
  45. return true;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement