October 2019
Beginner to intermediate
498 pages
14h 13m
English
Now we are ready to build our solar system, which will consist of a sun and a collection of planets, with each planet defined to be some distance away from the sun. We will assume that the sun resides at the center of the solar system. We will implement the SolarSystem class in the same way as we have implemented the other classes seen so far: by providing a constructor that will be responsible for defining the instance variables and by defining appropriate accessor and mutator methods.
The complete SolarSystem class is shown in LISTING 10.8. Our constructor (lines 2–4) assumes that a basic SolarSystem object must have a Sun object at its center. As a consequence, the constructor expects to receive ...
Read now
Unlock full access