java 点类程序找不到符号

来源:百度知道 编辑:UC知道 时间:2024/06/14 18:58:28
这是我写的代码
class point
{
point(double xx,double yy)
{
double x,y;
x=xx;
y=yy;
}
int equals(point b)
{
if(this.x==b.x && this.y==b.y)
return 0;
else
return 1;
}
}
public class testpoint
{
public static void main(String[] args)
{
System.out.println("Hello World!");
point m=new point(2,3);
point n=new point(3,4);
int p=m.equals(n);
if(p==0)
System.out.println("俩圆相等");
else if(p==1)
System.out.println("俩圆不相等");
}
}

运行提示说
testpoint.java:11: 找不到符号
符号: 变量 x
位置: 类 point
if(this.x==b.x && this.y==b.y)
^
testpoint.java:11: 找不到符号
符号: 变量 x
位置: 类 point
if(this.x==b.x && this.y==b.y)
^
testpoint.java:11: 找不到符号
符号: 变量 y

class point
{
double x,y; // 应定义为全局变量
point(double xx,double yy)
{
x=xx;
y=yy;
}
int equals(point b)
{
if(this.x==b.x && this.y==b.y)
return 0;
else
return 1;
}
}
public class test
{
public static void main(String[] args)
{
System.out.println("Hello World!");
point m=new point(2,3);
point n=new point(3,4);
int p=m.equals(n);
if(p==0)
System.out.println("俩圆相等");
else if(p==1)
System.out.println("俩圆不相等");
}
}

class point
{
point(double xx,double yy)
{
double x,y;
x=xx;
y=yy;
}
.......................
------------------------------------
class point
{
double x,y;
point(double xx,double yy)
{

this.x=xx;
this.y=yy;
}
.................