Final answer:
An interface called LibraryUser is created with methods for account registration and book requests. Classes KidUsers and AdultUser implement this interface and contain logic based on user age for book borrowing privileges.
Step-by-step explanation:
Creating Library User Interfaces and Classes
To create an online library application that caters to both adults and children, we start with an interface called LibraryUser. This interface will declare two methods: void registerAccount() and void requestBook(). Subsequently, two classes named KidUsers and AdultUser will implement the LibraryUser interface. Both classes will have two instance variables: age (of type int) and bookType (of type String).
In the KidUser class, the registerAccount method will check if the age is less than 12. If true, it will display the message "You have successfully registered under a Kids Account" to the console. The requestBook method in this class will allow users to borrow books from the "Kids" category for a period of 10 days. In contrast, the AdultUser class will cater to users above the age of 12, allowing them to borrow "Fiction" category books to be returned within 7 days.
This approach makes the application scalable for future additions of new user roles, where similar rules can be enforced through additional classes that implement the LibraryUser interface.