Answer the question
In order to leave comments, you need to log in
Need to develop a hierarchy of library workers?
Good afternoon!
please tell me (explain) what else needs to be done with this task with abstractions and interfaces.
I understand what needs to be done 4 interface Reader, interface Librarian, interface Supplier, interface Administrator. With my own classes, but then how it cuts off, I try to do it in IDEA.
Description
It is necessary to develop a hierarchy of library workers. It is necessary to implement the combination of several roles in the library in one executor through interfaces. Each object in the program has a specific set of actions.
Often the programmer who creates an object does not represent all the situations in which it will be used. Also, the programmer using the object often does not know all its details.
Interfaces are used to convey information about what an object should be able to do.
An example of interfaces in our library is the concept of a role on a project. Each role implies a set of specific operations that the user object must "be able to" - User in the program.
Functionality of the program
Create a hierarchy "Library Users" with the following interfaces:
Reader - takes and returns books.
Librarian orders books.
Book Supplier - Brings books to the library.
Administrator - finds and issues books and notifies of delays in the return time.
In the public static void main method, create 2-3 objects that implement these interfaces.
Additional Information
Please note that the user (User) can have several interfaces. Objects of class User can interact with each other (for example, a librarian orders from a supplier).
Implementation Example
For example, an administrator should have an overdueNotification(Reader reader) method. Methods can take other users as a parameter. For example, a reader borrows books from an administrator, a librarian orders from a supplier, and so on.
Create some classes that demonstrate the use of interfaces. In particular, demonstrate overlap, such as a provider who can also be a reader, a librarian who is an administrator, etc. The implementation of the methods described in interfaces is optional, but it is desirable to demonstrate how methods should be called on objects.
Answer the question
In order to leave comments, you need to log in
Good afternoon!
Create multiple interfaces.
For example, iReader, iLibrarian, iSupplier and iAdministrator. (The names are given for illustration purposes only. It is advisable to follow the Java naming convention)
Next, describe the methods for each interface.
For example, for iReader -
// сигнатуры методов могут отличаться
takeBook(); // взять книгу
returnBook(); // вернуть книгу
orderBook(); // заказать книгу
bringBook(); // принести книгу
findBook(); // найти книгу
overdueNotification(User reader); // уведомить о времени возврата
Reader implements iReader
Librarian implements iLibrarian
Supplier implements iSupplier
Admin implements iAdministrator
Admin implements iAdministrator, iReader
implement the required interface too. Reader extends User implements iReader
interface iReader<T extends User>
Reader extends User implements iReader<Reader>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question