-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRental.java
More file actions
41 lines (40 loc) · 1.09 KB
/
Rental.java
File metadata and controls
41 lines (40 loc) · 1.09 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
class Rental {
private Movie movie;
private int daysRented;
public Rental(Movie rentedMovie, int timeRented) {
movie = rentedMovie;
daysRented = timeRented;
}
public int getDaysRented() {
return daysRented;
}
public Movie getMovie() {
return movie;
}
double getCharge() {
double result = 0;
switch (getMovie().getMovieType()) {
case Movie.REGULAR:
result += 2;
if (getDaysRented() > 2)
result += (getDaysRented() - 2) * 1.5;
break;
case Movie.NEW_RELEASE:
result += getDaysRented() * 3;
break;
case Movie.CHILDRENS:
result += 1.5;
if (getDaysRented() > 3)
result += (getDaysRented() - 3) * 1.5;
break;
}
return result;
}
int getFrequentRenterPoints() {
if ((getMovie().getMovieType() == Movie.NEW_RELEASE) &&
getDaysRented() > 1)
return 2;
else
return 1;
}
}