二级JAVA上机题与答案!!!
来源:优易学  2010-1-15 14:50:04   【优易学:中国教育考试门户网】   资料下载   IT书店

 


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)的方式打印坐标的位置

 }

}

上一页  [1] [2] [3] 

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训