package liu0919; public class Point { //属性 private double x; private double y; private double d; //构造方法 Point(double x,double y) { this.x=x; this.y=y; this.d=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 liu0919; public class Ceshi_point { public static void main(String[] args) { Point po=new Point(5,6); System.out.println("原始大小x="+po.getX()+"y="+po.getY()); po.setY(8); po.setX(2); System.out.println("点大小x="+po.getX()+"y="+po.getY()); } }