April 2024
Beginner to intermediate
500 pages
24h 20m
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 that 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 and a list of planets. As a consequence, the constructor ...
Read now
Unlock full access