日期:2014-05-20 浏览次数:20841 次
public class ThreeD extends TwoD {
private int z;
public ThreeD(int x, int y,int z) {
super(x, y);
this.z = z;
}
public void display() {
System.out.println("这个空间点的坐标是:"+[color=#FF0000]x[/color]+","+[color=#FF0000]y[/color]+","+z);
}
public class TwoD {
private int x;
private int y;
public TwoD(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public void display() {
System.out.println("这个平面点的坐标是:" + x + "," + y);
}
}
public static void main(String[] args) {
TwoD Tpoint = new TwoD(4, 8);
TwoD thpoint = new ThreeD(20,30,40);
show(Tpoint);
show(thpoint);
}
public static void show(TwoD c){
c.display();
}