/
Newcomer_25
/
hw_constructor_formatted
Обзор
Документация
Войти
/
Newcomer_25
/
hw_constructor_formatted
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
37 строк
966 B
Newcomer_25
upload files
10 сен 2025, 20:05
10 сен 2025, 20:05
8e3c319
Код
Авторство
О чём код?
public class Book { public String title; public int releaseYear; public Author author; public 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) { return title.contains(word) || author.name.contains(word) || author.surname.contains(word); } public int estimatePrice() { double price = 3 * pages * (Math.sqrt(author.rating)); int floor = (int) Math.floor(price); return pages >= 250 ? (int) price : 0; } public String toString() { return "The book: " + title + "," + " released in " + releaseYear + " ," + author + " ," + pages + " pages."; } }