Java-09,练习

 我的代码

public class Point {
    private int x;
    private int y;
    private int z;
    
    public Point(int _x,int _y,int _z){
        x = _x;
        y = _y;
        z = _z;
    }
    
    public void setX(int i){
        x = i;
    }
    
    public void setY(int i){
        y = i;
    }
    
    public void setZ(int i){
        z = i;
    }
    
    public double distance(){
        return Math.sqrt( x*x+y*y+z*z);
    }
    
    public static void main(String[] args) {
        Point p1 = new Point(1,2,3);
        System.out.println(p1.distance());
    }
}
原文地址:https://www.cnblogs.com/nyist0/p/12355106.html