Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Explanation: Charging Fines to Patrons0:40 with Ashley Boucher
For our next step, let's discuss how to we could go about expanding our app so charges can be fined to patrons with overdue books.
Instructions for Workspace
Your instructions are as follows:
1) Add a property called
dailyFine, initialized to
.1, to the Library class constructor method.
2) Add a property called
balance, initialized to
0, to the Patron class constructor method.
3) Add a method called
chargeFines() to the Library class that finds all Patrons with overdue books and charges them the daily fine for every day their book is late.
Our library system can do a lot now.
New patrons and books can be added to the library, and
patrons can check out books and return them.
But what happens if a patron doesn't return their book on time?
In real life, that patron will be fined.
This can happen in our library system, too.
We can write a method on the library class that handles this.
The method could find all the patrons who have overdue books, and
fine them a certain amount per day that they are overdue.
That amount can be kept in a property on the library class called daily fine.
We'll make our daily fine $0.10.
Additionally, our patron class also needs a new property in the constructor method,
balance, and it should be initialized to zero.
You need to sign up for Treehouse in order to download course files.Sign up