Typically you need access methods for each instance variable,
a getter and a setter for each. Also a toString()
method should be included.
Cone
classHere is the complete design:
ConeA class that represents a right circular cone
Variables
private double height; // height of the cone
private double radius; // radius of the circular base
Constructor
public Cone( double radius, double height )
Creates a new instance of a Cone object with the specified height and radiusMethods
public double area()
calculates and returns the area of the conepublic double volume()
calculates and returns the volume of the conepublic void setHeight()
changes the height of a conepublic void setRadius()
changes the radius of a conepublic double getHeight()
returns the height of a conepublic double getRadius()
returns the radius of a conepublic String toString()
returns reference to a string describing the cone
The set
methods may be used to change the values in selected instance variables
and get
methods may be used to access the values.
(More on this later.)
Is this design enough to start coding?