y;}//把当前点移到新的位置(x,y)上
public String toString(){return "("+x+","+y+")";}//
以(x,y)的格式返回点的位置
public void translate(int x,int y){this.x +=
x;this.y += y;}//在原有坐标上分别增加x和y
public static void main(String args[]){
//*********Found********
//生成一个对象(5,5)
Java_3 p=new Java_3(5,5);
System.out.println("x="+ p.x+" y="+ p.y);
System.out.println("Location is"+ p.toString());//
以(x,y)的方式打印坐标的位置
//*********Found********
//在原有位置上增加(3,4)
p.translate(3,4);
System.out.println("x="+ p.x+" y="+ p.y);//打印横
坐标和纵坐标的值
System.out.println("Location is"+ p.toString());//
以(x,y)的方式打印坐标的位置
}
}
责任编辑:cyth