用JAVA定义一个圆类,再定义高,衍生出圆锥类,能求圆的面积和圆锥体积,求大神写一下。菜鸟级别,
1个回答
展开全部
圆类
/**
* Created by Administrator on 2017-3-3.
*/
public class Circular {
private double r;
public double getAcreage()
{
return Math.PI*r*r;
}
}
圆锥
/**
* Created by Administrator on 2017-3-3.
*/
public class Cone {
private Circular circular;
private double height;
public double getVolume()
{
return circular.getAcreage()*height*(1/3);
}
}
/**
* Created by Administrator on 2017-3-3.
*/
public class Circular {
private double r;
public double getAcreage()
{
return Math.PI*r*r;
}
}
圆锥
/**
* Created by Administrator on 2017-3-3.
*/
public class Cone {
private Circular circular;
private double height;
public double getVolume()
{
return circular.getAcreage()*height*(1/3);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询