You would expect:
Any other attributes of a cone can be calculated from these two.
Cone
class
Object oriented design means deciding what classes you need,
what data the objects hold,
and how the objects behave.
Let us do that with the Cone
class.
Here is the beginning of our 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( ,, , )
Creates a new instance of a Cone object with the specified height and radiusMethods
. . . . . .
Instance variables (like height
) are usually made private
so
that only the constructors and methods of the object may access them.
Constructors are usually made public
.
What parameters should the Cone
constructor have? Fill in the blanks.