/
h2r
/
Class_structure
Обзор
Документация
Войти
/
h2r
/
Class_structure
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
32 строки
1 KB
h2r
Class structure
09 окт 2025, 05:04
09 окт 2025, 05:04
4b5ebe0
Код
Авторство
О чём код?
class Book { String title; int releaseYear; Author author; // Перенос автора из класса Author 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 lowerWord = word.toLowerCase(); return title.toLowerCase().contains(lowerWord) || author.name.toLowerCase().contains(lowerWord) || author.surname.toLowerCase().contains(lowerWord); } // Рассчет стоимость книги public int estimatePrice() { double price = 3 * pages * Math.sqrt(author.rating); int finalPrice = (int) Math.floor(price); return finalPrice < 250 ? 250 : finalPrice; } }