java.awt.Color getColor();
}
class Colored<T extends HasColor>{
T item;
Colored(T item){
this.item = item;
}
java.awt.Color color(){
//调用HasColor接口实现类的getColor()方法
return item.getColor();
}
}
class Dimension{
public int x, y, z;
}
Class ColoredDimension<T extends Dimension & HasColor>{
T item;
ColoredDimension(T item){
this.item = item;
}
T getItem(){
return item;
}
java.awt.Color color(){
//调用HasColor实现类中的getColor()方法
return item.getColor();
}
//获取Dimension类中定义的x,y,z成员变量
int getX(){
return item.x;
}
int getY(){
return item.y;
}
int getZ(){
return item.z;
}
}
interface Weight{
int weight();
}
class Solid<T extends Dimension & HasColor & Weight>{
T item;
Solide(T item){
this.item = item;
}
T getItem(){
return item;
}
java.awt.Color color(){
//调用HasColor实现类中的getColor()方法
return item.getColor();
}
//获取Dimension类中定义的x,y,z成员变量
int getX(){
return item.x;
}
int getY(){
return item.y;
}
int getZ(){
return item.z;
}
int weight(){
//调用Weight接口实现类的weight()方法
return item.weight();
}
}
class Bounded extends Dimension implements HasColor, Weight{
public java.awt.Color getColor{
return null;
}
public int weight(){
return 0;
}
}
public class BasicBounds{
public static void main(String[] args){
Solid<Bounded> solid = new Solid<Bounded>(new Bounded());
solid.color();
solid.getX();
solid.getY();
solid.getZ();
solid.weight();
}
}