![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Define the Sphere
class. Include a
radius
instance variable, with a setter and getter. Then, use the
setter and getter to define a volume
method for instances of the
Sphere
class.
Next, alter the class definition such that the instance variable is
diameter
, rather than radius
. Write a getter and setter for
the diameter
variable. Write a getter and setter for the radius
derived attribute. Check your volume
method to be
sure that it still provides correct answers, without change, even though the
detailed representation for sphere instances has changed.