/
Anna_Drobysheva
/
Zadanie4
Обзор
Документация
Войти
/
Anna_Drobysheva
/
Zadanie4
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Book.java
60 строк
3 KB
Anna_Drobysheva
create: Book.java
17 май 2026, 12:59
Верифицирован
17 май 2026, 12:59
2516698
Код
Авторство
О чём код?
public class Book { String title; int releaseYear; String author; int pages; public Book(String title, int releaseYear, String 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.contains(word); } public int estimatePrice() { int price = pages * 3; return Math.max(price, 250); } public static void main(String[] args) { Book book1 = new Book("Война и мир", 1869, "Лев Толстой", 1274); Book book2 = new Book("Колобок", 1873, "Афанасьев", 12); Book book3 = new Book("Мастер и Маргарита", 1967, "Михаил Булгаков", 480); System.out.println("=== Книга 1: " + book1.title + " ==="); System.out.println("Автор: " + book1.author); System.out.println("Год выпуска: " + book1.releaseYear); System.out.println("Страниц: " + book1.pages); System.out.println("Большая книга? " + book1.isBig()); System.out.println("Содержит слово 'Толстой'? " + book1.matches("Толстой")); System.out.println("Содержит слово 'Пушкин'? " + book1.matches("Пушкин")); System.out.println("Оценочная стоимость: " + book1.estimatePrice() + " руб."); System.out.println(); System.out.println("=== Книга 2: " + book2.title + " ==="); System.out.println("Автор: " + book2.author); System.out.println("Год выпуска: " + book2.releaseYear); System.out.println("Страниц: " + book2.pages); System.out.println("Большая книга? " + book2.isBig()); System.out.println("Содержит слово 'Колобок'? " + book2.matches("Колобок")); System.out.println("Оценочная стоимость: " + book2.estimatePrice() + " руб."); System.out.println(); System.out.println("=== Книга 3: " + book3.title + " ==="); System.out.println("Автор: " + book3.author); System.out.println("Год выпуска: " + book3.releaseYear); System.out.println("Страниц: " + book3.pages); System.out.println("Большая книга? " + book3.isBig()); System.out.println("Содержит слово 'Булгаков'? " + book3.matches("Булгаков")); System.out.println("Оценочная стоимость: " + book3.estimatePrice() + " руб."); } }