Write:
- an interface
Colorablewith one method,String howToColor(); - an abstract class
Shapewith the abstract methodsgetArea()andgetName(); Square(extendsShape, implementsColorable: "color all four sides"),Disc(extendsShapeonly) andFlag(width, height, number of stripes; implementsColorable: "color each of the 3 stripes separately").
ColorableApp reads the number of shapes, then lines square side, disc radius or flag width height stripes, and stores them in a Shape[]. For each shape it prints the name and the area, then — only if the object is Colorable — how to color it. For the input
5
square 2
disc 1
flag 3 2 3
square 4.5
disc 2.5
the program prints
Square of side 2.0, area 4.00: color all four sides
Disc of radius 1.0, area 3.14: cannot be colored
Flag 3.0 by 2.0, area 6.00: color each of the 3 stripes separately
Square of side 4.5, area 20.25: color all four sides
Disc of radius 2.5, area 19.63: cannot be colored
3 of 5 shapes are Colorable