-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathParcel10.java
More file actions
37 lines (29 loc) · 833 Bytes
/
Parcel10.java
File metadata and controls
37 lines (29 loc) · 833 Bytes
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
package innerclasses;
/**
* RUN:
* javac innerclasses/Parcel10.java && java innerclasses.Parcel10
* OUTPUT:
* Too much more then budget!
*/
public class Parcel10 {
public Destination destination(final String dest, final float price)
{
return new Destination() {
private int cost;
{
cost = Math.round(price);
if (cost > 100) {
System.out.println("Too much more then budget!");
}
}
private String label = dest;
public String readLabel() {
return label;
}
};
}
public static void main(String[] args) {
Parcel10 p = new Parcel10();
Destination d = p.destination("Tasmania", 101.395F);
}
}