package test;

class Point {
    int x;
    int y;
    String name="no name";
    Point()
    {
        x=0;
        y=0;
    }
    Point(int x,int y,String name)
    {
        this.x=x;
        this.y=y;
        this.name=name;
    }
    void move(int x,int y)
    {
        this.x=x;
        this.y=y;
    }
    void newname(String name)
    {
        this.name=name;
    }
    int  equal(int x,int y)
    {
        return this.x==x?(this.y==y?1:0):0;
    }
    void getx()
    {
        System.out.println(x);
    }
    void gety()
    {
        System.out.println(y);
    }
    void getname()
    {
        System.out.println(name);
    }
}
public class Main {
  public static void main(String args[])
  {
     Point a=new Point();
     a.getx();
     a.gety();
     a.getname();
     a.move(20, 20);
     a.newname("GXM");
     a.getx();
     a.gety();
     a.getname();
     if(a.equal(20,20)==1)
         System.out.println("OK");
     else
         System.out.println("NO");
     if(a.equal(20,21)==1)
         System.out.println("OK");
     else
         System.out.println("NO");
      
  }
}

   输出入下:

   

0
0
no name
20
20
GXM
OK
NO

posted on 2013-01-08 21:43  一把刷子  阅读(111)  评论(0编辑  收藏  举报