/
Letta21
/
HWClassConstructMethods
Обзор
Документация
Войти
/
Letta21
/
HWClassConstructMethods
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
36 строк
1 KB
Letta21
upload files
15 сен 2025, 15:22
15 сен 2025, 15:22
1dba498
Код
Авторство
О чём код?
public class Book { public String title; public int releaseYear; public int pages; public int rating; public Author auth; public Book(String title, int releaseYear, int pages, Author auth) { this.title = title; this.releaseYear = releaseYear; this.pages = pages; this.auth = auth; } public boolean isBig() { return (pages > 500);// true; } public boolean matches(String word) { return title.contains(word) || auth.name.contains(word) || auth.surname.contains(word); } public int estimatePrice() { double r = auth.rating; double floor; double sqrt = Math.sqrt(r); floor = (pages * 3) * sqrt;//нашли квадр корень r = Math.floor(floor);//округлили до целого int price = (int) r;//привели к int if (price < 250) { return 250; } else { return price; } } }