GUI and Graphics Case Study Exercises
10.1 Modify the MyLine
, MyOval
and MyRectangle
classes of GUI and Graphics Case Study Exercise 8.1 and Exercise 9.1 to create the class hierarchy in Fig. 10.17. Classes of the MyShape
hierarchy should be “smart” shape classes that know how to draw themselves (if provided with a Graphics
object that tells them where to draw). Once the program creates an object from this hierarchy, it can manipulate it polymorphically for the rest of its lifetime as a MyShape
.
In your solution, class MyShape
in Fig. 10.17 must be abstract
. Since MyShape
represents any shape in general, you cannot ...
Get Java™ How To Program (Early Objects), Tenth 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.