当前位置: 技术问答>请帮忙看看!!!!!!!!!!!!!!!!!!!!!
iis7站长之家
请帮忙看看这个程序!!!!
来源: 互联网 发布时间:2015-07-15
本文导语: class Point { int x,y; String name="A point"; Point() { x=0;y=0; } Point(int x,int y,String name) { this.x=x; this.y=y; this.name=name; } int getX() { return x; } int getY() { return y; } void move(int newX,int newY) { x=newX; y=newY; } ...
class Point
{
int x,y;
String name="A point";
Point()
{
x=0;y=0;
}
Point(int x,int y,String name)
{
this.x=x;
this.y=y;
this.name=name;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
void move(int newX,int newY)
{
x=newX;
y=newY;
}
Point newP(String name)
{
Point P=New Point(-x,-y,name);
return P;
}
boolean equal(int x,int,y)
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
void()print()
{
System.out.println(name+"x="+x+"y="+y);
}
}
public class UsingObject
{
public static void main(String args[])
{
Point P=new Point();
p.point();
p.move(50,50);
System.out.println("**after moving**");
System.out.println("Get x and y directly");
System.out.println("x="+P.x+"y="+P.y);
System.out.println("or Get x and y by calling method");
System.out.println("x="+P.getX()+"y="+P.getY());
if(P.equal(50,50))
System.out.println("I like this point!!!!");
else
System.out.println("I hate it!!!!");
P.newPoint("A new point:").point();
newPoint(10,15,"Another new point").point();
}
}
--------------------Configuration: JDK version 1.4 --------------------
C:JCreatorMyProjectsApplet.javaUsingObject.java:30: ';' expected
Point P=New Point(-x,-y,name);
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:33: expected
boolean equal(int x,int,y)
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:43: ')' expected
}
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:30: cannot resolve symbol
symbol : variable New
location: class Point
Point P=New Point(-x,-y,name);
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:33: missing method body, or declare abstract
boolean equal(int x,int,y)
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:50: cannot resolve symbol
symbol : variable p
location: class UsingObject
p.point();
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:51: cannot resolve symbol
symbol : variable p
location: class UsingObject
p.move(50,50);
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:61: cannot resolve symbol
symbol : method newPoint (java.lang.String)
location: class Point
P.newPoint("A new point:").point();
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:62: cannot resolve symbol
symbol : method newPoint (int,int,java.lang.String)
location: class UsingObject
newPoint(10,15,"Another new point").point();
^
9 errors
Process completed.
我是新手﹐学了不到两个月。请各位给与帮助﹗
请问这几种错误出错的原因在哪里﹖(能挨个问题解释将感激不尽)这几种错误经常见到尤其是”)”的错误更是搞不懂﹐为什么会有这样的错误呢?我碰到过好多次了。还有就是cannot resolve symbol这种错误一般是因为什么才出现的﹖
{
int x,y;
String name="A point";
Point()
{
x=0;y=0;
}
Point(int x,int y,String name)
{
this.x=x;
this.y=y;
this.name=name;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
void move(int newX,int newY)
{
x=newX;
y=newY;
}
Point newP(String name)
{
Point P=New Point(-x,-y,name);
return P;
}
boolean equal(int x,int,y)
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
void()print()
{
System.out.println(name+"x="+x+"y="+y);
}
}
public class UsingObject
{
public static void main(String args[])
{
Point P=new Point();
p.point();
p.move(50,50);
System.out.println("**after moving**");
System.out.println("Get x and y directly");
System.out.println("x="+P.x+"y="+P.y);
System.out.println("or Get x and y by calling method");
System.out.println("x="+P.getX()+"y="+P.getY());
if(P.equal(50,50))
System.out.println("I like this point!!!!");
else
System.out.println("I hate it!!!!");
P.newPoint("A new point:").point();
newPoint(10,15,"Another new point").point();
}
}
--------------------Configuration: JDK version 1.4 --------------------
C:JCreatorMyProjectsApplet.javaUsingObject.java:30: ';' expected
Point P=New Point(-x,-y,name);
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:33: expected
boolean equal(int x,int,y)
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:43: ')' expected
}
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:30: cannot resolve symbol
symbol : variable New
location: class Point
Point P=New Point(-x,-y,name);
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:33: missing method body, or declare abstract
boolean equal(int x,int,y)
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:50: cannot resolve symbol
symbol : variable p
location: class UsingObject
p.point();
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:51: cannot resolve symbol
symbol : variable p
location: class UsingObject
p.move(50,50);
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:61: cannot resolve symbol
symbol : method newPoint (java.lang.String)
location: class Point
P.newPoint("A new point:").point();
^
C:JCreatorMyProjectsApplet.javaUsingObject.java:62: cannot resolve symbol
symbol : method newPoint (int,int,java.lang.String)
location: class UsingObject
newPoint(10,15,"Another new point").point();
^
9 errors
Process completed.
我是新手﹐学了不到两个月。请各位给与帮助﹗
请问这几种错误出错的原因在哪里﹖(能挨个问题解释将感激不尽)这几种错误经常见到尤其是”)”的错误更是搞不懂﹐为什么会有这样的错误呢?我碰到过好多次了。还有就是cannot resolve symbol这种错误一般是因为什么才出现的﹖
|
class Point
{
int x,y;
String name="A point";
Point()
{
x=0;y=0;
}
Point(int x,int y,String name)
{
this.x=x;
this.y=y;
this.name=name;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
void move(int newX,int newY)
{
x=newX;
y=newY;
}
Point newP(String name)
{
Point P=New Point(-x,-y,name);
return P;
}
boolean equal(int x,int y)
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
void print()
{
System.out.println(name+"x="+x+"y="+y);
}
}
public class UsingObject
{
public static void main(String args[])
{
Point P=new Point();
P.point();
P.move(50,50);
System.out.println("**after moving**");
System.out.println("Get x and y directly");
System.out.println("x="+P.x+"y="+P.y);
System.out.println("or Get x and y by calling method");
System.out.println("x="+P.getX()+"y="+P.getY());
if(P.equal(50,50))
System.out.println("I like this point!!!!");
else
System.out.println("I hate it!!!!");
P.newPoint("A new point:").point();
newPoint(10,15,"Another new point").point();
}
}
{
int x,y;
String name="A point";
Point()
{
x=0;y=0;
}
Point(int x,int y,String name)
{
this.x=x;
this.y=y;
this.name=name;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
void move(int newX,int newY)
{
x=newX;
y=newY;
}
Point newP(String name)
{
Point P=New Point(-x,-y,name);
return P;
}
boolean equal(int x,int y)
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
void print()
{
System.out.println(name+"x="+x+"y="+y);
}
}
public class UsingObject
{
public static void main(String args[])
{
Point P=new Point();
P.point();
P.move(50,50);
System.out.println("**after moving**");
System.out.println("Get x and y directly");
System.out.println("x="+P.x+"y="+P.y);
System.out.println("or Get x and y by calling method");
System.out.println("x="+P.getX()+"y="+P.getY());
if(P.equal(50,50))
System.out.println("I like this point!!!!");
else
System.out.println("I hate it!!!!");
P.newPoint("A new point:").point();
newPoint(10,15,"Another new point").point();
}
}
|
(1)Point P=New Point(-x,-y,name); //New应该为小写new
(2)boolean equal(int x,int,y) //int,y中间无逗号
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
(3) Point P=new Point();
p.point();//p为大写且没有point这个方法
p.move(50,50);//p为大写
(4) P.newPoint("A new point:").point(); //没有定义newPoint这个方法啊。
newPoint(10,15,"Another new point").point();
写程序的时候要细致,感觉都是不细致导致的问题。
(2)boolean equal(int x,int,y) //int,y中间无逗号
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
(3) Point P=new Point();
p.point();//p为大写且没有point这个方法
p.move(50,50);//p为大写
(4) P.newPoint("A new point:").point(); //没有定义newPoint这个方法啊。
newPoint(10,15,"Another new point").point();
写程序的时候要细致,感觉都是不细致导致的问题。
|
太粗心了,我大致改了一下,试试吧
我看你不适合编程,变量名前后不一致,方法名前后不一致,错字一大堆
class Point
{
int x,y;
String name="A point";
Point()
{
x=0;y=0;
}
Point(int x,int y,String name)
{
this.x=x;
this.y=y;
this.name=name;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
void move(int newX,int newY)
{
x=newX;
y=newY;
}
Point newP(String name)
{
Point P=new Point(-x,-y,name);
return P;
}
boolean equal(int x,int y)
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
void print()
{
System.out.println(name+"x="+x+"y="+y);
}
}
public class UsingObject
{
public static void main(String args[])
{
Point p=new Point();
p.print();
p.move(50,50);
System.out.println("**after moving**");
System.out.println("Get x and y directly");
System.out.println("x="+p.x+"y="+p.y);
System.out.println("or Get x and y by calling method");
System.out.println("x="+p.getX()+"y="+p.getY());
if(p.equal(50,50))
System.out.println("I like this point!!!!");
else
System.out.println("I hate it!!!!");
p.newP("A new point:").print();
new Point(10,15,"Another new point").print();
}
}
我看你不适合编程,变量名前后不一致,方法名前后不一致,错字一大堆
class Point
{
int x,y;
String name="A point";
Point()
{
x=0;y=0;
}
Point(int x,int y,String name)
{
this.x=x;
this.y=y;
this.name=name;
}
int getX()
{
return x;
}
int getY()
{
return y;
}
void move(int newX,int newY)
{
x=newX;
y=newY;
}
Point newP(String name)
{
Point P=new Point(-x,-y,name);
return P;
}
boolean equal(int x,int y)
{
if(this.x==x&&this.y==y)
return true;
else
return false;
}
void print()
{
System.out.println(name+"x="+x+"y="+y);
}
}
public class UsingObject
{
public static void main(String args[])
{
Point p=new Point();
p.print();
p.move(50,50);
System.out.println("**after moving**");
System.out.println("Get x and y directly");
System.out.println("x="+p.x+"y="+p.y);
System.out.println("or Get x and y by calling method");
System.out.println("x="+p.getX()+"y="+p.getY());
if(p.equal(50,50))
System.out.println("I like this point!!!!");
else
System.out.println("I hate it!!!!");
p.newP("A new point:").print();
new Point(10,15,"Another new point").print();
}
}
|
正是因为刚开始学啊,所以更要注意啊!
养成良好的编程习惯,对一个程序员是很重要的!
猪你成功!
养成良好的编程习惯,对一个程序员是很重要的!
猪你成功!
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。