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

    1 今天写了cone类

    题目要求

     

     

     

     

     

     

     

     

    程序源代码:

    package Plane;
    public class Cone extends Circle{
      double height;
      Cone(){}
      Cone(double xx,double yy,double rr,double hh)
      {
           super(xx,yy,rr);
              height=hh;
              System.out.println("Cone Constructor run");
       }
       Cone(Cone v)
       {
        super(v);
           height=v.height;
           System.out.println("Cone CopyConstructor run");
       }
        void setH(double hh){height=hh;}
           double getH(){return height;}
        void show()                      //用于显示球的信息
        {
         System.out.print("Cone(");
            super.show();
            System.out.print(",Height="+height+")");
        }
         double s_Area()          //用于计算球的面积
          {
              double s;
              double r=getR();
              double l=Math.pow((r*r+height*height),0.5);
              s=PI*r*r+PI*r*l;
              return s;
          }
          double volume()          //用于计算球的体积
          {
              double v;
              double r=getR();
              v=PI*r*r*height/3;
              return v;
          }
    }
     
    package Plane;
    import java.util.Scanner;
    public class ConeMa extends Cone{
     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(Cone s){/*立体图形的体积函数*/
      System.out.println("Volumn="+s.volume());
     }
     void s_Area(Cone s){/*立体图形的表面积函数*/
      System.out.println("S_Area="+super.s_Area());
     }
     public static void main(String[] args)
     {
       double  h;
       Scanner in=new Scanner(System.in);
       h=in.nextDouble();
          Cone co1=new Cone(1,2,3,4);
          Cone co2=new Cone(co1);
          ConeMa m=new ConeMa();
       m.show(co1);
       System.out.println();
       m.area(co1);
       m.length(co1);
       m.s_Area(co1);
       m.volumn(co1);
       co2.setH(h);
       m.show(co2);
       System.out.println();
       m.area(co2);
       m.length(co2);
       m.s_Area(co2);
       m.volumn(co2);
       in.close();
     }
    }

    运行截图:

     

     

    2 今天没什么问题

    3 明天继续写题

  • 相关阅读:
    NOIP模拟 回文序列
    NOIP模拟 最佳序列
    BZOJ 2783 树
    BZOJ 3631 松鼠的新家
    洛谷 6道简单图论
    NOI模拟 颜色
    NOIP模拟 Game
    BZOJ1415 聪聪与可可
    Codeforces Round #443 (Div. 2) C: Short Program
    20171028洛谷NOIP模拟
  • 原文地址:https://www.cnblogs.com/linmob/p/13345761.html
Copyright © 2011-2022 走看看