class Movie


1 public class Movie
2 {
3     public static final int CHILDRENS = 2;
4     public static final int REGULAR = 0;
5     public static final int NEW_RELEASE = 1;
6 
7     private String _title;
8     private int _priceCode;
9 
10     public Movie(String title, int priceCode)
11     {
12 	_title = title;
13 	_priceCode = priceCode;
14     }
15 
16     public int getPriceCode()
17     {
18 	return _priceCode;
19     }
20 
21     public void setPriceCode(int priceCode)
22     {
23 	_priceCode = priceCode;
24     }
25 
26     public String getTitle()
27     {
28 	return _title;
29     }
30 
31     public double getCharge(int daysRented) 
32     {
33 	double result = 0;
34 	switch (getPriceCode()) {
35 	case REGULAR:         
36 	    result += 2;         
37 	    if (daysRented > 2)
38 		result += (daysRented - 2) * 1.5;
39 	    break;     
40 	case NEW_RELEASE:    
41 	    result += daysRented * 3;     
42 	    break;     
43 	case CHILDRENS: 
44 	    result += 1.5;  
45 	    if (daysRented > 3)   
46 		result += (daysRented - 3) * 1.5;   
47 	    break; 
48 	}
49 	return result;
50     }
51 
52     public int getFrequentRenterPoints(int daysRented)
53     {
54 	if(_priceCode == NEW_RELEASE && daysRented > 1)
55 	    return 2;
56 	else
57 	    return 1;
58     }
59 }