Providing toString() methods

exercise No. 167

Q:

Consider:

final Circle c = new Circle(-2, -1, 3.5);
final Rectangle r = new Rectangle(3, 1, 1.5, 4.4);

System.out.println(c);
System.out.println(r);

This creates the following output:

de.hdm_stuttgart.mi.sd1.shape.model.Circle@659e0bfd
de.hdm_stuttgart.mi.sd1.shape.model.Rectangle@2a139a55

This result is due to the invocation of the toString() method being defined in the Object superclass. Override this method in Shape, Circle and Rectangle accordingly to get:

Circle (-2.0,-1.0), radius=3.5
Rectangle (3.0,1.0), width=1.5, height=4.4

Provide appropriate unit tests.

Tip

You may access Shape.toString() from derived classes by using super().

A: