注册 登录
编程论坛 JAVA论坛

这段代码很长,想起大神看看,能否给各行个注释

白白的爆炸 发布于 2017-06-17 23:06, 1827 次点击
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 newpoint(String name){
    point newp=new point(-x,-y,name);
    return newp;
}
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.getY()+"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 ").print();
            new point (10,15,"another new point").print();
    }

}
我能理解大部分,但有一些我不清楚是如何调用的...
4 回复
#2
流氓兔1号2017-06-18 16:07
各行给个注释没有必要吧!都是些简单的函数,你随便找本书看看就有,或者具体不理解哪些你说清楚点,不然别人不知道你哪不懂
#3
白白的爆炸2017-06-18 17:14
回复 2楼 流氓兔1号
抱歉,有点着急,我试着将我理解的注释一下,能帮我看一下我不理解的部分吗?
#4
流氓兔1号2017-06-19 22:13
回复 3楼 白白的爆炸
可以的,不懂的你发过来,大家互相学习,互相进步
#5
LG隐2017-06-20 16:05
调用不懂你先根据函数名,然后看他的参数就能确定到底是调用的哪个函数了。
1