Objects in Action
Consider the case of the program that displays a pie chart. A PieChart object could consist of the following:
• Behavior to calculate the size of each pie slice
• Behavior to draw the chart
• An attribute to store the title of the chart
It might seem odd to ask the PieChart object to draw itself because graphs don’t draw themselves in the real world. Objects in OOP work for themselves whenever possible. This quality makes it easier to incorporate them in other programs. If a PieChart object did not know how to draw itself, for instance, every time you used that PieChart object in another program, you would have to create behavior to draw it.
Note
An autodialer is software that uses a modem to dial a series of phone numbers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access