Programming Practice Deitel and Deital, 4th edition, Chapter 19
19.8 Many programs written with inheritance could be solved with composition instead, and vice versa. Discuss the relative merits of these approaches in the context of the Point, Circle, Cylinder class hierarchy in this chapter. Rewrite the program of Fig. 19.10 (and the supporting classes to use composition rather than inheritance. After you do this reassess the relative merits of the two approaches both for the Point, Circle, Cylinder problem and for object oriented programs in general.
19.11 Write and inheritance hierarchy for class Quadrilateral (四邊形), Trapezoid (梯形), Parallelogram (平行四邊形), Rhombus (菱形), Rectangle (長方形), and Square (正方形). Use Quadrilateral as the base class of the hierarchy. Make the hierarchy as deep (i.e., as many levels) as possible. The private data of Quadrilateral should be the (x, y) coordinate pairs for the four endpoints of the Quadrilateral. Write a driver program that instantiates and displays objects of each of these classes.