class Book {
private String author;
private String title;
private String body;
public Book(String author, String title, String body) {
this.author = author;
this.title = title;
this.body = body;
}
public String getAuthor() {
return author;
}
public String getTitle() {
return title;
}
public String getBody() {
return body;
}
}
class Shelf {
private String id;
private Book[] books;
public Shelf(String id, Book[] books) {
this.id = id;
this.books = books;
}
public String getId() {
return id;
}
public Book[] getBooks() {
return books;
}
}
class Library {
private Shelf[] shelves;
public Library(Shelf[] shelves) {
this.shelves = shelves;
}
public int countAuthor(String authorName) {
int count = 0;
for (Shelf shelf : shelves) {
Book[] books = shelf.getBooks();
for (Book book : books) {
if (book.getAuthor().equals(authorName)) {
count++;
}
}
}
return count;
}
}