Specifies the kinds of objects to create using a prototypical instance, and
creates new objects by copying this prototype.
Category:
Creational
UML Diagram:
Description of the Demonstration:
Anyone who has ever played Dungeons and Dragons as a Dungeon Master knows the
difficulty in creating multiple instances of certain creatures. In this
demonstration of the Prototype Design Pattern a MonsterRegistry creates single
instances of all creatures that will be needed in a game when the application
starts up. When an instance of one of these creatures is needed the appropriate
creature is located and a Clone() function is called on it which will return
a duplicate instance of the monster "prototype."
Code:
Click here to download a
zip file containing all the source files and an executable of the
Demonstration. See the _ReadMe.txt file in the zip.