-
Notifications
You must be signed in to change notification settings - Fork 0
/
Movie.java
45 lines (38 loc) · 1.16 KB
/
Movie.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
public class Movie {
public static final int CHILDRENS = 2;
public static final int REGULAR = 0;
public static final int NEW_RELEASE = 1;
private String _title;
private Price _price;
public Movie(String title, int priceCode) {
_title = title;
setPriceCode(priceCode);
}
public String getTitle() {
return _title;
}
public int getPriceCode() {
return _price.getPriceCode();
}
public void setPriceCode(int priceCode) {
switch (priceCode) {
case REGULAR:
_price = new RegularPrice();
break;
case CHILDRENS:
_price = new ChildrensPrice();
break;
case NEW_RELEASE:
_price = new NewReleasePrice();
break;
default:
throw new IllegalArgumentException("Incorrect Price Code");
}
}
public double getCharge(int daysRented) {
return _price.getCharge(daysRented);
}
public int getFrequentRenterPoints(int daysRented) {
return _price.getFrequentRenterPoints(daysRented); // Delegando a responsabilidade
}
}