Topic: add问题。高手帮我看看怎么返回值

  Print this page

1.add问题。高手帮我看看怎么返回值 Copy to clipboard
Posted by: gashi
Posted on: 2005-05-21 10:45

public class point{
private int x;
private int y;
public point(int px,int py){
this.x = px;
this.y = py;
}
public point(){
this.x=0;
this.y=0;
}
public int getX(){
return x;
}
public int getY(){
return y;
}
public String toString(){
return ("("+x+","+y+")");
}
public point add(point p){
希望算出2点坐标的和(this.x+p.getX(),this.y+p.getY())
?????
}
}

2.Re:add问题。高手帮我看看怎么返回值 [Re: gashi] Copy to clipboard
Posted by: why
Posted on: 2005-05-21 10:54

> 希望算出2点坐标
??? What are you talking about?

return new Point(this.x + p.getX(), this.y + p.getY()); // by convention use uppercase for the first character of a class.

3.Re:add问题。高手帮我看看怎么返回值 [Re: gashi] Copy to clipboard
Posted by: gashi
Posted on: 2005-05-21 11:02

这样写之后,编译还是出很多错为什么阿

4.Re:add问题。高手帮我看看怎么返回值 [Re: gashi] Copy to clipboard
Posted by: qizi
Posted on: 2005-05-21 11:57

这个方法该是:

public String toString(){
return ("("+String.valueOf(x)+","+String.valueOf(y)+")");

public point add(point p){
this.x=+p.getX();
this.y=+p.getY();
return this;

}
希望行

Disable Smileys

5.Re:add问题。高手帮我看看怎么返回值 [Re: gashi] Copy to clipboard
Posted by: qizi
Posted on: 2005-05-21 11:57

晕,这个有字符变形!你把他复制下来看!

6.Re:add问题。高手帮我看看怎么返回值 [Re: gashi] Copy to clipboard
Posted by: 8166680
Posted on: 2005-05-23 01:39

有点收获


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923