public abstract class Shape {
public Shape( double x, double y ) {
this.x = x;
this.y = y;
}
protected double x;
protected double y;
public abstract void show( );
public void move( double xMoveData,double yMoveData ) {
x += xMoveData;
y += yMoveData;
}
}//
package Shapes;
public class Point extends Shape {
public Point( double x, double y ) {
super( x, y );
}
public Point( Point aPoint ) {
super( aPoint.x, aPoint.y );
}
package Shapes;
import Shapes.*; public class BeeLine extends Point {
public BeeLine( double xStartData, double yStartData, double xEndData, double yEndData ) {
super( xStartData,yStartData );
end = new Point( xEndData, yEndData );
}///
import Shapes.*;
public class TryShape {
public static void main( String [ ] args ) {
BeeLine beeLine = new BeeLine( 2, 2, 1, 1 );
Point end = new Point( 1, 1 );
beeLine.show( );
System.out.println( beeLine );
System.out.println( "直线的长度是:" + beeLine.length( end ) );
}
} 编译的时没有出现错误 在运行的时候得到(NULL):(1.0,1.0)
在public class BeeLine extends Point 中的super( xStartData,yStartData );
后面加上start = new Point( xStartData,yStartData );就可以得到我想的结果
(2.0, 2.0):(1.0,1.0)麻烦帮我看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货