/
konick
/
Netology-class-intro
Обзор
Документация
Войти
/
konick
/
Netology-class-intro
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
40 строк
1 KB
konick
4 домашнее задание
28 окт 2025, 21:44
28 окт 2025, 21:44
195d7a1
Код
Авторство
О чём код?
package hw4; public class Book { public static int MIN_PRICE = 250; public static int BIG_BOOK_PAGES = 500; 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 > BIG_BOOK_PAGES; } public boolean matches(String word) { word = word.toLowerCase(); return title.toLowerCase().contains(word) || author.name.toLowerCase().contains(word) || author.surname.toLowerCase().contains(word); } public int estimatePrice() { int price = (int) Math.floor(pages * 3 * Math.sqrt(author.rating)); return Math.max(price, MIN_PRICE); } public String getInfo() { return "Книга: '" + title + "'. Автор книги: '" + author.getInfo() + "'. Год выпуска: '" + releaseYear + "' Количество страниц: " + pages; } }