zoukankan      html  css  js  c++  java
  • java 接口练习题6

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

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

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

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

    4)编写主类程序验证。

    public class Point {
        private int a,b,c;
        Point (int a,int b,int c)
        {
            this.a=a;
            this.b=b;
            this.c=c;
        }
        public int getA() {
            return a;
        }
        public void setA(int a) {
            this.a = a;
        }
        public int getB() {
            return b;
        }
        public void setB(int b) {
            this.b = b;
        }
        public int getC() {
            return c;
        }
        public void setC(int c) {
            this.c = c;
        }
        public void Juli()
        {
            System.out.println("坐标"+a+","+b+","+c+"距离原点的距离的平方="+(a*a+b*b+c*c));
        }
        public static void main(String[] args) {
            Point p=new Point(2,2,2);
            p.Juli();
            p.setA(3);
            p.setB(5);
            p.setC(9);
            p.Juli();
        }

  • 相关阅读:
    python—pandas及DataFrame
    python模块以及import 报错:ImportError: No module named myModule
    第二周开课测试
    第二周开课博客
    javaweb第二课
    javaweb第一课
    大道至简.读后感
    读后感2
    读后感.1
    测试
  • 原文地址:https://www.cnblogs.com/jskbk/p/5531951.html
Copyright © 2011-2022 走看看