星空网 > 软件开发 > Java

空间点

 1 public class Point { 2   private double x; 3   private double y; 4   private double z; 5  6   public double getX() { 7     return x; 8   } 9 10   public void setX(double x) {11     this.x = x;12   }13 14   public double getY() {15     return y;16   }17 18   public void setY(double y) {19     this.y = y;20   }21 22   public double getZ() {23     return z;24   }25 26   public void setZ(double z) {27     this.z = z;28   }29 30   public Point(double x, double y, double z) {31     this.x = x;32     this.y = y;33     this.z = z;34   }35 36   public void getJuLi() {37     System.out.println("点(" + x + "," + y + "," + z + ")距离原点的平方=" + (x * x + y * y + z * z));38   }39 40   public static void main(String[] args) {41     Point p = new Point(5, 3, 8);42     p.setY(-2.5);43     p.getJuLi();44 45     Point p1 = new Point(-1, 3, 5);46     p1.getJuLi();47 48   }49 50 }

定义一个“点”(Point)类用来表示三维空间中的点(有三个坐标)。要求如下:

(1)可以生成具有特定坐标的点对象。

(2)提供可以设置三个坐标的方法。

(3)提供可以计算该“点”距原点距离平方的方法。

(4)编写主类程序验证。

空间点




原标题:空间点

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

越南海运中国:https://www.goluckyvip.com/tag/97558.html
中国越南海运:https://www.goluckyvip.com/tag/97559.html
AR功能:https://www.goluckyvip.com/tag/9756.html
中国越南海运时间:https://www.goluckyvip.com/tag/97560.html
出口海运到菲律宾:https://www.goluckyvip.com/tag/97561.html
海运出口到菲律宾:https://www.goluckyvip.com/tag/97562.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
北京丰台区水上乐园哪家好玩?:https://www.vstour.cn/a/366177.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流