dimanche 2 octobre 2022

How to set field value of class A using an object of class B? What type of relationship should be between the classes to do so?

I have a Library class which has a librarian and list of book and Librarian class which has an id and addBook method. The librarian class can add books in the library. What will be the correct way to do this?

public class Library 
{
 private Librarian librarian;
 private List<Book> books;
}

public class Librarian
{
 private int id;
 public boolean addBook(Book b);
}

Aucun commentaire:

Enregistrer un commentaire