Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started