01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package types.point5;
import java.awt.Color;
interface Colored {
Color getColor();
}
interface Point {
double getX();
double getY();
}
interface ColoredPoint
extends Colored, Point
{ }
final class CartesianPoint implements ColoredPoint {
/* ... */
}
final class PolarPoint implements ColoredPoint {
/* ... */
}
public class Main {
private Main() {}
public static void printColoredPoint(ColoredPoint cp) {
System.out.println(cp.getX());
System.out.println(cp.getY());
System.out.println(cp.getColor());
}
public static void main(String[] args) {
printColoredPoint(new CartesianPoint(0,0,Color.RED));
printColoredPoint(new PolarPoint(0,0,Color.RED));
}
}
|