10.3 Designing and Implementing a Planet Class

We now turn our attention to solving the problem of building a model of the solar system. To do so will require that we consider the specific data used in the model. Even with the rich set of built-in classes provided by Python, it is often preferable to describe our problem and solution in terms of classes that are specifically designed to represent the objects in the problem. We begin by building a simple representation of a planet; we will then design and implement a Planet class.

To design a class to represent the idea of a planet, we need to consider the data the planet objects will need to know about themselves—that is, their instance data. The values of the instance data will help to differentiate ...

Get Python Programming in Context, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.