2019.12.25 继承习题

/**
* Test19.java
* com.DuiXiang
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年12月25日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/

package com.DuiXiang;
/**
* ClassName:Test19
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年12月25日 上午10:11:39
*
* @see
*/
public class Test19 {
public static void main(String[] args) {
Cylinder cylinder = new Cylinder();
System.out.println(cylinder.findVolume());
}
}
class Circle2 {
private double radius;
public Circle2() {

radius=1;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public double findArea() {
return Math.PI*radius*radius;
}

}
class Cylinder extends Circle2{
private double length;
public Cylinder() {
length=1;

}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public double findVolume() {
return findArea()*length;
}
}

猜你喜欢

转载自www.cnblogs.com/aojie/p/12095353.html
今日推荐