public class point {
int x,y;
point(int x,int y){
this.x=x;
this.y=y;
}
public point() {
this( 0, 0 );
}
public double distance() {
return Math.sqrt( x*x + y*y );
}
}
public class point3d extends point{
int z;
point3d(int x,int y,int z){
super( x, y );
this.z = z;
}
public point3d() {
this( 0, 0, 0 );
}
public double distance() {
return Math.sqrt( x*x + y*y + z*z);
}
public static void main(String[] args) {
// TODO 自动生成方法存根
point p = new point( 1, 1 );
System.out.println( "p.distance() = " + p.distance() );
p = new point3d(1,1,1 );
System.out.println( "p.distance() = " + p.distance() );
}
}
int x,y;
point(int x,int y){
this.x=x;
this.y=y;
}
public point() {
this( 0, 0 );
}
public double distance() {
return Math.sqrt( x*x + y*y );
}
}
public class point3d extends point{
int z;
point3d(int x,int y,int z){
super( x, y );
this.z = z;
}
public point3d() {
this( 0, 0, 0 );
}
public double distance() {
return Math.sqrt( x*x + y*y + z*z);
}
public static void main(String[] args) {
// TODO 自动生成方法存根
point p = new point( 1, 1 );
System.out.println( "p.distance() = " + p.distance() );
p = new point3d(1,1,1 );
System.out.println( "p.distance() = " + p.distance() );
}
}