/
Pavel23
/
HW6
Обзор
Документация
Войти
/
Pavel23
/
HW6
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
37 строк
1 KB
Pavel23
upload files
09 окт 2025, 15:09
09 окт 2025, 15:09
c366c2f
Код
Авторство
О чём код?
public class Book { public String title; public int releaseYear; public Author author; public int pages; public Book(String title, int releaseYear, String authorName, String authorSurname, int authorRating, int pages) { this.title = title; this.releaseYear = releaseYear; this.author = new Author(authorName, authorSurname, authorRating); this.pages = pages; } public boolean isBig() { return pages > 500; } public boolean matches(String word) { if (title.contains(word) || author.name.contains(word) || author.surname.contains(word)) { return true; } else return false; } public int estimatePrice() { int cost = (int) Math.floor((pages * 3) * Math.sqrt(author.rating)); if (cost > 250) { return cost; } else return 250; } public String toString() { return "Название: " + title + "\nАвтор: " + author + "\nСтраниц: " + pages + "\nГод издания: " + releaseYear; } }