height and radius (same as for Cone
)
Here is a summary of class Cone
:
// instance variables private double radius; // radius of the base private double height; // height of the cone // constructor public Cone( double radius, double height ) // methods public double area() public double volume() public void setHeight( double height ) public void setRadius( double radius ) public double getHeight( ) public double getRadius( )
Here is a summary of class Cylinder
:
// instance variables private double radius; // radius of the base private double height; // height of the cone // constructor public Cylinder( double radius, double height ) // methods public double area() public double volume() public void setHeight( double height ) public void setRadius( double radius ) public double getHeight( ) public double getRadius( )
The classes are nearly the same. Of course, the methods for area and volume use different formulas. Here is the source code:
Could an object of type Tree
contain a instance variable that points to a Cone
?