-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathMovie.java
More file actions
46 lines (38 loc) · 1.13 KB
/
Movie.java
File metadata and controls
46 lines (38 loc) · 1.13 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
public class Movie {
public static final int CHILDRENS = 2;
public static final int REGULAR = 0;
public static final int NEW_RELEASE = 1;
private String titulo;
private Price preco;
public Movie(String title, int priceCode) {
this.titulo = title;
setPriceCode(priceCode);
}
public String getTitle() {
return titulo;
}
public int getPriceCode() {
return preco.getPriceCode();
}
public void setPriceCode(int arg) {
switch (arg) {
case REGULAR:
preco = new RegularPrice();
break;
case CHILDRENS:
preco = new ChildrensPrice();
break;
case NEW_RELEASE:
preco = new NewReleasePrice();
break;
default:
throw new IllegalArgumentException("Código de preço incorreto");
}
}
public double getCharge(int daysRented) {
return preco.getCharge(daysRented);
}
public int getFrequentRenterPoints(int daysRented) {
return preco.getFrequentRenterPoints(daysRented);
}
}