Solution

ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2015/object-oriented-programming/1/d/i/solution

The UML class diagram separates text shared by every displayable item from numeric formatting shared only by numeric items. A dashed hollow-triangle arrow denotes realization of a Java interface; solid hollow-triangle arrows denote class inheritance. Both kinds of arrow point towards the more general type.
Figure 1.
Data interface realization and inheritance for string, integer and real display items
. Details.
AbstractData owns alignment and computes length from the current rendered text. NumericData adds the minimum digit width. IntegerData and RealData each own their numeric value, while RealData alone owns the minimum number of decimal places. The numeric formatting object methods do not belong on Data: ordinary text has no meaningful setPlaces operation. The design choice is

New to topics? Read the docs here!