标签:private package public return double
package com.ctgu.java; public class Circle { private double radius; public Circle(){ this.radius = 1; } public double getRadius() { return radius; } public void setRadius(double radius) { this.radius = radius; } public double findArea(){ return Math.PI* radius*radius; } } package com.ctgu.java; public class Cylinder extends Circle { private double length; public Cylinder(){ length = 1; } public double getLength() { return length; } public void setLength(double length) { this.length = length; } public double findVolume(){ //return Math.PI*this.getRadius()*this.getRadius()*length; return findArea()*length; } } package com.ctgu.java; public class TestCylinder { public static void main(String[] args) { Cylinder c = new Cylinder(); double area = c.findVolume(); System.err.println(area); c.setRadius(2.3); c.setLength(1.2); area = c.findVolume(); System.out.println(area); } }
标签:private package public return double
原文地址:http://9815936.blog.51cto.com/9805936/1605789