Hi,
I suggest an improvement: Push up the definitions of name, getName() and setName() into the superclass Q2_Vector_Shapes, instead of duplicating them in each subclass.
Benefits:
> Code reuse
> Avoids code duplication
> Avoids type based checks. Instead of code like
you can utilize
polymorphism like this:
The advantage is that if you introduce a new shape subclass like Triangle in future, you won't have to change this for-loop.
Cheers
Karthik