1 Displayed

Lab 4, CSC 102, Spring 2012

Put all of the tests and examples of data for this lab in a class called Lab4. You may name your package whatever you like :).

1 Displayed

A Displayed is either a piece of Text with a string, a color, and a point size, or an Image, with a width and height in centimeters.

Develop the hierarchy described in the previous paragraph, including an interface and two classes that implement it.

Provide at least one example of each kind of the data.

For each of the following, you must follow the design recipe, including a one-line comment and a test case for each kind of data. Develop the test cases before you write the method bodies.

First, develop the width method on this hierarchy. The width of a piece of text is determined by dividing the point size by 28 and multiplying by the number of characters. The width of an image is specified as one of its fields.

Next, develop the goodForKids method on this hierarchy. A piece of text is good for kids if it’s no more than 20 characters. An image is always good for kids.

Finally, develop the convertToText method on this hierarchy. A piece of text stays the same, and an image is converted to the text "<image>", in black, at a size of 25 pts.

Show me this code for lab credit.