Introduction to OOP: Chapter 20 : A Second Look at Classes
[next]
[previous]
[audio]
[real]
[text]
Example - Lines and Pens
-
Suppose we have an object that can draw a line.
-
From it we build an object
that remembers it's location and can can be moved on the screen - a Pen.
-
From this we can build a different pen that remembers different locations,
but we don't need to redo the drawing code.
-
Alternatively, we can create a different object that remembers its location
and its orientation - a Turtle.
-
Alternatively, we can create a different object that draws four copies of
any drawing command in reflections.
Intro OOP, Chapter 20, Slide 12
The idea of a turtle comes from the programming language LOGO.