-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patron.java
52 lines (40 loc) · 1.47 KB
/
Patron.java
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
49
50
51
52
/**
* @author lioraryepaz
* This class represents a Patron, which has a first name, last name and different literary prefrences.
*/
class Patron {
final String firstName;
final String lastName;
int comicTendency;
int dramaticTendency;
int educationalTendency;
/**
* The minimal literary value a book must have for this patron to enjoy it
*/
int enjoymentThreshold;
Patron(String patronFirstName, String patronLastName, int patronComicTendency, int patronDramaticTendency,
int patronEducationalTendency, int patronEnjoymentThreshold) {
firstName = patronFirstName;
lastName = patronLastName;
comicTendency = patronComicTendency;
dramaticTendency = patronDramaticTendency;
educationalTendency = patronEducationalTendency;
enjoymentThreshold = patronEnjoymentThreshold;
}
String stringRepresentation() {
return firstName + " " + lastName;
}
/**
* @return Returns the literary value this patron assigns to the given book.
*/
int getBookScore(Book book) {
return book.getComicValue() * comicTendency + book.getDramaticValue() * dramaticTendency +
book.getEducationalValue() * educationalTendency;
}
/**
* will enjoy a given book according to his threshold
*/
boolean willEnjoyBook(Book book) {
return (getBookScore(book) > enjoymentThreshold);
}
}