| 6 | // construction on an anonymous inner class |
| 7 | |
| 8 | public class Parcel10 { |
| 9 | public Destination |
| 10 | destination(final String dest, final float price) { |
| 11 | return new Destination() { |
| 12 | private int cost; |
| 13 | // Instance initialization for each object: |
| 14 | { |
| 15 | cost = Math.round(price); |
| 16 | if(cost > 100) |
| 17 | System.out.println("Over budget!"); |
| 18 | } |
| 19 | private String label = dest; |
| 20 | @Override |
| 21 | public String readLabel() { return label; } |
| 22 | }; |
| 23 | } |
| 24 | public static void main(String[] args) { |
| 25 | Parcel10 p = new Parcel10(); |
| 26 | Destination d = p.destination("Tasmania", 101.395F); |
| 27 | } |
| 28 | } |
| 29 | /* Output: |
| 30 | Over budget! |
| 31 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected