Select Page

Prototype

Prototype

Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

Source Code

/**  * Declares interface for cloning itself.  * @role __Prototype  */ public interface Prototype {         Prototype createCopy();}  /**  * Implements an operation for cloning itself.  */ public class ConcretePrototype1 implements Prototype {         protected ConcretePrototype1(ConcretePrototype1 prototype)          {            // initialize new copy with prototype         }          public Prototype createCopy() {            return new ConcretePrototype1(this);                 } }  /**  * Implements an operation for cloning itself.  */ public class ConcretePrototype1 implements Prototype {         protected ConcretePrototype1(ConcretePrototype1 prototype) {           // initialize new copy with prototype         }          public Prototype createCopy() {                 return new ConcretePrototype1(this);                 } } 
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments

Categories

0
Would love your thoughts, please comment.x
()
x