-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.java
More file actions
48 lines (39 loc) · 1.62 KB
/
Copy pathBook.java
File metadata and controls
48 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class Book {
String title;
int releaseYear;
// String author;
int pages;
Author author;
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() {
System.out.println("Является ли книга большой?");
if (pages > 500) {
return true;
} else {
return false;
}
}
// метод проверки содержимого слова в название книги и имени автора
public boolean matches(String word) {
System.out.println("Содержится ли в описании книги (названии,в имени и фамилии автора) переданное параметром слово?");
String tempName = author.getName();
String tempSurname = author.getSurname();
if (title.contains(word) || tempName.contains(word) || tempSurname.contains(word)) {
return true;
} else {
return false;
}
}
public int estimatePrice() {
double price = pages * 3 *Math.sqrt(author.getRating()); // расчет цены 3 рубля за страницу с учетом рейтинга
int roundPrice = (int)Math.floor(price); //округляем вниз
int result = Math.max(roundPrice, 250);//
return result;
}
}