[Pattern] (Prototype) There is an error in this exemple that i read on a book?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

As you can see, all methods getSea, getPlains, getForest are fully implemented inside the main class (TerrainFactory), and at runtime they are the only that are used. For what reason in UML diagram the same methods are override in each sublclass (Earth and Mars) ?

I would say that either there is, in fact, an editorial error there, or possibly just poor layout making it appear that the code sample and diagram go together when they actually don't, since based on the diagram, TerrainFactory should be abstract with two concrete factory classes as its children.

Yes, in fact it's abstract, or not (it's have italic name)?
I wouldn't say that the implementation is wrong, the UML concept is.
Because assuming that the UML is right, i should implement the same methods for each subclass, causing of course redundant code where it's not necessary.
Assuming that the methods equally have the same beavhior indipendent from the subclass, i think it's right to refer to this behaviors encapsluing them into the main class. No override is needed