zoukankan      html  css  js  c++  java
  • 【每日日报】第十四天

    1 今天写了Cylinder类

    题目要求:

     

     

     

     

     

     

     

     程序源代码:

    package Plane;
    public class Cylinder extends Circle{
      double height;
      Cylinder(){super(0,0,0);height=0;}
      Cylinder(double xx,double yy,double rr,double hh)
          {
          super(xx,yy,rr);
              height=hh;
              System.out.println("Cylinder Constructor run");
          }
          Cylinder(Cylinder v)
          {
           super(v);
              height=v.height;
              System.out.println("Cylinder CopyConstructor run");
          }
          void setH(double hh){height=hh;}
          double getH(){return height;}
          void show()                    //用于显示球的信息
          {
           System.out.print("Cylinder(");
              super.show();
              System.out.println(",Height="+height+")");
          }
          double s_Area()          //用于计算球的面积
          {
              double s;
              double r=getR();
              s=2*PI*r*r+2*PI*r*height;
              return s;
          }
          double volume()          //用于计算球的体积
          {
              double v;
              double r=getR();
              v=PI*r*r*height;
              return v;
          }
    }
     
    package Plane;
    import java.util.Scanner;
    public class CylinderMa extends Cylinder{
     void show(Point p){/*点基类的显示函数*/
         p.show();
     }
     void length(Plane p){/*平面图形的周长函数*/
      System.out.println("Length="+p.length());
     }
     void area(Plane p){/*平面图形的面积函数*/
      System.out.println("Area="+p.area());
     }
     void volumn(Cylinder s){/*立体图形的体积函数*/
      System.out.println("Volumn="+s.volume());
     }
     void s_Area(Cylinder s){/*立体图形的表面积函数*/
      System.out.println("S_Area="+s.s_Area());
     }
     public static void main(String[] args)
     {
      double  h;
      Scanner in=new Scanner(System.in);
      h=in.nextDouble();
      Cylinder cy1=new Cylinder(1,2,3,4);
      Cylinder cy2=new Cylinder(cy1);
      CylinderMa m=new CylinderMa();
      m.show(cy1);
      System.out.println();
      m.area(cy1);
      m.length(cy1);
      m.s_Area(cy1);
      m.volumn(cy1);
      cy2.setH(h);
            m.show(cy2);
            System.out.println();
            m.area(cy2);
            m.length(cy2);
         m.s_Area(cy2);
         m.volumn(cy2);
         in.close();
     }
    }

     运行截图:

     

     

    2 打代码的速度比以前快了很多,有一些问题不用百度自己也知道怎么回事了

    3 明天继续做题

  • 相关阅读:
    vimrc 配置 史上最牛
    nmap 黑客 端口扫描(转)
    linux export 命令(转)
    【引用】linux下编译静态库ranlib有什么用
    vim map nmap(转)
    vim 自定义命令 自定义快捷键(转)
    vimrc初学 vim 快捷键 map(转)
    vim 取消 查找 高亮
    Java内存模型(JMM)学习总结
    Struts2和Spring整合
  • 原文地址:https://www.cnblogs.com/linmob/p/13345731.html
Copyright © 2011-2022 走看看