Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // check out the book only if it is in the list of available
- // only if the person is a patron and the book is in the library and not currently checked out.
- // update the book in the library not the book being passed into the method.
- // update the due date for the book object
- // return true if the book is successfully checked out and false otherwise
- public boolean checkOut(Person p, Book b, String dueDate){
- // see if the person is in the name list
- if (!this.getPatrons().contains(p)){
- return false;
- }
- // see if the book is in the library and not get checked out
- if (!this.getLibraryBooks().contains(b)){
- return false;
- }
- if (dueDate.length() != 10){
- return false;
- }
- // update the due date of the book in the arrayList
- // a for loop is needed to change the actual book in the person
- for (Book loopBook: this.l){
- // checks if the book
- if (loopBook.equals(b) && loopBook.isCheckedOut() == false){
- // sets the dues date, assigns it to the person
- loopBook.setDueDate(dueDate);
- p.addBook(loopBook);
- // changes the ischecked out book
- loopBook.setCheckedOut(true);
- return true;
- }
- }
- // return true or false
- // decrease the number of books in the library
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement