10.3 Designing and Implementing a Planet Class

We now turn our attention to solving the problem of building a software model of the solar system. To do so, we need to 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, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.