java 需要标识符

来源:百度知道 编辑:UC知道 时间:2024/05/24 11:26:32
这个程序的错误怎么解决?

public class point
{
private int x,y;
public point(int x,int y)
{
this.x=x;this.y=y;
}
public int getx()
{
return x;
}
public int gety()
{
return y;
}
}
class line
{
private p1,p2;
line(point a,point b)
{
p1=new point(a.getx(),a.gety());
p2=new point(b.getx(),b.gety());
}
public double length()
{
return Math.sqrt(Math.pow(p2.getx()-p1.getx(),2)+Math.pow

(p2.gety()-p1.gety(),2));
}
}

public class point {
private int x, y;

public point(int x, int y) {
this.x = x;
this.y = y;
}

public int getx() {
return x;
}

public int gety() {
return y;
}
}

class line {
private point p1, p2;

line(point a, point b) {
p1 = new point(a.getx(), a.gety());
p2 = new point(b.getx(), b.gety());
}

public double length() {
return Math.sqrt(Math.pow(p2.getx() - p1.getx(), 2) + Math.pow

(p2.gety() - p1.gety(), 2));
}
}

class point
{
private int x,y;
public point(int x,int y)
{
this.x=x;this.y=y;
}
public int getx()
{
return x;
}
public int gety()
{
return y;
}
}

public class Line
{
private point p1,p2; //这里缺少一个point类型声明,如果想让程序运行,还要有一个main方法.
Line(point a,point b)