![]() |
![]() |
![]() |
![]() |
![]() |
|
In Segment 114, you defined an
instance method for the Integer class that computes volumes. That
method is sent to receivers that are instances of the Integer class.
Another approach is to create a Volume class and to define class
methods for that class that computes volumes. Such methods resemble
functions in standard programming languages, inasmuch as the receiver does
not enter into the computations performed inside the method.
Define sphere: to be a Volume class method, with an argument
representing a sphere's radius. Use your method to calculate the volume of
Earth in cubic miles.