创建一个Point类,有成员变量x,y,方法getX(),setX(),还有一个构造方 法初始化x和y。创建类主类A来测试它。

package com.chuoji;

public class Point {

    
        private double x;
        private double y;
        private double a;
         
      
        Point(double x,double y)
        {
            this.x=x;
            this.y=y;
            this.a=x+y;
        }
         
         
       
        public double getX() {
            return x;
        }
     
        public void setX(double x) {
            this.x = x;
        }
     
        public double getY() {
            return y;
        }
     
        public void setY(double y) {
            this.y = y;
        }
         
    }
    
package com.chuoji;

public class Text00 {

    public static void main(String[] args) {
        
        
         Point b=new Point(2,3);
            System.out.println("原始状态x="+b.getX()+"y="+b.getY());
             
            b.setY(4);
            b.setX(6);
            System.out.println("改变状态x="+b.getX()+"y="+b.getY());
     
        

    }

}

posted @ 2016-09-20 17:55  戳记  阅读(429)  评论(0编辑  收藏  举报