Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Explanation: Checking Out and Returning Books1:24 with Ashley Boucher
For the next step in our library application, let's start discussing how patrons can check out and return books.
Instructions for Workspace
Your instructions are as follows:
1) Inside the Book class, add three properties to the constructor method:
outproperty should be initialized to
dueDateproperty should be initialized to
patronproperty should be initialized to
Now that we've written the methods for the library class, we can start thinking about
how to implement the methods in our patron class, check out and return book.
Our rough plan didn't have any methods for the book class, so for
now we don't have to worry about that.
As we know from our experience with real-life libraries,
a patron has the ability to check out a book.
We need to write a method on our patron class that models this activity.
Our check out method has to do something to indicate that the patron
has checked out a book.
One obvious way to do this is to set the patrons currentBook property
to the book object representing the book that's being checked out.
Setting the currentBook property can be done in the checkout method.
Having this property is great because the library employee can see what book
any given patron has checked out at any time.
But wait a second.
This doesn't seem like enough to me.
Shouldn't this information go two ways?
I think a library employee should be able to look up any book object,
see if it's been checked out, and who checked it out and see when it's due.
This is where we have to both expand on a rough plan and
go on a little bit of a coding tangent.
Information like whether a book has been checked out, who checked it out and
when it's due should probably be properties on the book class, right?
Let us go back and add those.
Open up the attached work space to find an updated read me and
follow the instructions.
There is a summary of what we discussed in this video in the following
You need to sign up for Treehouse in order to download course files.Sign up