Question: Let us continue with the example of TheRevengers. Create 3 superheroes from The Revengers and then clone those superheroes using the concept of the Prototype
Let us continue with the example of TheRevengers. Create superheroes from The Revengers and then clone those superheroes using the concept of the Prototype pattern.
The superheroes to be cloned are : TheMagician, Axon The Slayer and Manic The Mayhem.
The steps to achieve the solution for this problem are as follows:
Create the Revenger interface which declares the clone method
Create the superhero classes which define the clone function
Create the superhero factory which defines the prototypes for the superheroes
Create the Revenger Prototype factory which takes the command line input and gives the desired output as mentioned below
Sample inputoutput looks like:
Command line input:
java PrototypeFactory TheMagician AvonTheSlayer Manic
Sample output:
The Magician
Avon TheSlayer
This prototype with the following name: Manic, doesn't exist
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
