/
yzupa
/
project.7
Обзор
Документация
Войти
/
yzupa
/
project.7
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
45 строк
1 KB
yzupa
upload files
13 янв 2026, 12:43
13 янв 2026, 12:43
b7ac4ee
Код
Авторство
О чём код?
public class Main { public static void main(String[] args) { Book book1 = new Book("Война и мир", 1869, "Лев Толстой", 1225); Book book2 = new Book("Колобок", 2020, "Народ", 20); System.out.println("Книга 1: " + book1.title); System.out.println("Большая? " + (book1.isBig() ? "Да" : "Нет")); System.out.println("Найдено по слову 'Толстой': " + book1.matches("Толстой")); System.out.println("Цена: " + book1.estimatePrice() + " руб."); System.out.println("---"); System.out.println("Книга 2: " + book2.title); System.out.println("Большая? " + (book2.isBig() ? "Да" : "Нет")); System.out.println("Цена (минимум 250): " + book2.estimatePrice() + " руб."); } } class Book { public String title; public int releaseYear; public String author; public 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); } }