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. 0:00 New patrons and books can be added to the library, and 0:02 patrons can check out books and return them. 0:05 But what happens if a patron doesn't return their book on time? 0:08 In real life, that patron will be fined. 0:11 This can happen in our library system, too. 0:13 We can write a method on the library class that handles this. 0:16 The method could find all the patrons who have overdue books, and 0:19 fine them a certain amount per day that they are overdue. 0:23 That amount can be kept in a property on the library class called daily fine. 0:26 We'll make our daily fine $0.10. 0:30 Additionally, our patron class also needs a new property in the constructor method, 0:32 balance, and it should be initialized to zero. 0:37
You need to sign up for Treehouse in order to download course files.Sign up