0% found this document useful (0 votes)
2 views2 pages

Interface

The document outlines the requirements for an online library application catering to two user roles: Adults and Children. It specifies the implementation of a LibraryUser interface with methods for account registration and book requests, along with the logic for KidUsers and AdultUsers classes. Additionally, it describes the creation of a Playable interface and its implementation in music-related classes, with a demonstration of their functionality in a Test class.

Uploaded by

darshanmarvel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Interface

The document outlines the requirements for an online library application catering to two user roles: Adults and Children. It specifies the implementation of a LibraryUser interface with methods for account registration and book requests, along with the logic for KidUsers and AdultUsers classes. Additionally, it describes the creation of a Playable interface and its implementation in music-related classes, with a demonstration of their functionality in a Test class.

Uploaded by

darshanmarvel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

An online library application need to be created for two types of users/roles-Adults

and children. Both of


these users should be able to register an account. Any user who is less than 12
years of age will be
registered as a child and they can borrow a “Kids” category book for 10 days,
whereas an adult can borrow “Fiction” category books which need to be returned
within 7 days. Note: In future, more users/roles might be added to the library
where similar rules will be enforced.
Develop Interfaces and classes for the categories mentioned above.
1. Create an interface LibraryUser with the following methods
void registerAccount()
void requestBook()
2. Create 2 classes “KidUsers” and “AdultUser” which implements the
LibraryUser interface.
3. Both the classes should have two instance variables - age(int),bookType(String)
4. The methods in the KidUser class should perform the following logic.
registerAccount():
if age < 12, a message displaying “You have successfully registered under a Kids
Account” should be displayed in the console.
If(age>12), a message displaying, “Sorry, Age must be less than 12 to register as a
kid” should be displayed in the console.
requestBook():
if bookType is “Kids”, a message displaying “Book Issued successfully, please
return the book within 10 days” should be displayed in the console,else, a message
displaying, “Oops, you are allowed to take only kids books” should be displayed in
the console.
5. The methods in the AdultUser class should perform the following logic.
registerAccount():
if age > 12, a message displaying “You have successfully registered under an
Adult Account” should be displayed in the console.
If age<12, a message displaying, “Sorry, Age must be greater than 12 to register as
an adult” should be
displayed in the console.
requestBook function:
if bookType is “Fiction”, a message displaying “Book Issued successfully, please
return the book within 7
days” should be displayed in the console., else, a message displaying, “Oops, you
are allowed to take only adult Fiction books” should be displayed in the console.
6. Create a class “LibraryInterfaceDemo.java” with a
main method and test the functionalities by creating
objects of KidUser and AdultUser classes.

2.
Write an interface called Playable, with a method void play();
Let this interface be placed in a package called music.
Write a class called Veena which implements Playable
interface. Let this class be placed in a package music.string
Write a class called Saxophone which implements Playable interface. Let this class
be placed in a package music.wind
Write another class Test in a package called live. Then,
a. Create an instance of Veena and call play() method
b. Create an instance of Saxophone and call play()
method
c. Place the above instances in a variable of type
Playable and then call play()

You might also like