Java问题,急急急,求帮忙
答案:1 悬赏:30 手机版
解决时间 2021-01-26 14:55
- 提问者网友:趣果有间
- 2021-01-26 07:42
Java问题,急急急,求帮忙
最佳答案
- 五星知识达人网友:一秋
- 2021-01-26 08:41
照着说明来写就好了,
public class Circle {
private double radius;
public Circle() {
this(0);
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public Circle(double radius) {
this.radius = radius;
}
public double getArea() {
return 3.14 * radius * radius;
}
public double getPerimeter() {
return 3.14 * radius * 2;
}
}
public class Cylinder extends Circle {
private double high;
public Cylinder(double r, double h) {
super(r);
this.high = h;
}
public double getVolume() {
return getArea() * high;
}
public void showVolume() {
System.out.println("Volume" + getVolume());
}
}
public class Test {
public static void main(String[] args) {
Circle c = new Circle(1);
System.out.println(c.getRadius());
System.out.println(c.getArea());
System.out.println(c.getPerimeter());
Cylinder cl = new Cylinder(1, 1);
System.out.println(cl.getVolume());
}
}
public class Circle {
private double radius;
public Circle() {
this(0);
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public Circle(double radius) {
this.radius = radius;
}
public double getArea() {
return 3.14 * radius * radius;
}
public double getPerimeter() {
return 3.14 * radius * 2;
}
}
public class Cylinder extends Circle {
private double high;
public Cylinder(double r, double h) {
super(r);
this.high = h;
}
public double getVolume() {
return getArea() * high;
}
public void showVolume() {
System.out.println("Volume" + getVolume());
}
}
public class Test {
public static void main(String[] args) {
Circle c = new Circle(1);
System.out.println(c.getRadius());
System.out.println(c.getArea());
System.out.println(c.getPerimeter());
Cylinder cl = new Cylinder(1, 1);
System.out.println(cl.getVolume());
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯