/
Yuretz78
/
BookAuthor1
Обзор
Документация
Войти
/
Yuretz78
/
BookAuthor1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
41 строка
1 KB
Yuretz78
create: Author.java, Book.java, Main.java
29 апр 2026, 17:57
Верифицирован
29 апр 2026, 17:57
8a448f2
Код
Авторство
О чём код?
public class Book { private String title; private int releaseYear; private Author author; // Поле теперь типа Author, а не String private int pages; public Book(String title, int releaseYear, Author author, int pages) { this.title = title; this.releaseYear = releaseYear; this.author = author; this.pages = pages; } public boolean isBig() { return pages > 500; } public boolean matches(String word) { // Объединяем имя и фамилию для единого поиска String fullAuthorInfo = author.getName() + " " + author.getSurname(); return title.contains(word) || fullAuthorInfo.contains(word); } public int estimatePrice() { double pricePerPage = 3 * Math.sqrt(author.getRating()); double totalPrice = pages * pricePerPage; int roundedPrice = (int) Math.floor(totalPrice); return Math.max(roundedPrice, 250); } public String toString() { return "Book{" + "title='" + title + '\'' + ", releaseYear=" + releaseYear + ", author=" + author + ", pages=" + pages + '}'; } }