331929879

          一個(gè)繼承類

          class Circle
          {
           int r;
           static double PI=3.14;
           public int GetR(int r)
           {
            this.r=r;
            return r;
           }
           public void GetZ()
           {
            System.out.println(2*PI*r);
           }
           public void GetArea()
           {
            System.out.println(PI*r*r);
           }
          }
          class Cylinder extends Circle
          {
           int height;
           public void GetCylinder(int r,int height)
           {
            this.r=r;
            this.height=height;
           }
           public void GetZ()
           {
            System.out.println(PI*r*r*height);
           }
           public void GetArea()
           {
            System.out.println(2*PI*r*r+2*PI*height);
           }
          }
          class Ex
          {
           public static void main(String args[])
           {
            Circle p=new Circle();
            System.out.println( p.GetR(2));
            p.GetZ();
            p.GetArea();
            Cylinder p1=new Cylinder();
            p1.GetZ();
           }
          }

          posted on 2007-10-11 15:09 小飛 閱讀(176) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 福鼎市| 新竹县| 塔河县| 新绛县| 错那县| 济南市| 万山特区| 镇雄县| 屯昌县| 青冈县| 海原县| 蓝田县| 砀山县| 卫辉市| 广昌县| 密山市| 茶陵县| 玉田县| 莲花县| 大英县| 黔东| 通州市| 德格县| 乌拉特后旗| 鄂伦春自治旗| 东乡族自治县| 五大连池市| 龙泉市| 金阳县| 交城县| 和顺县| 滁州市| 华安县| 富阳市| 温州市| 红桥区| 汉源县| 玉山县| 二手房| 墨玉县| 水富县|