/** * Created on 28.03.2005 * * @author Jens Guenther */ package de.unirostock.Prototype.example; public class ShipFactory { private static ShipFactory itsInstance; private Ship itsShipPrototype; private int itsShipProduced = 0; private ShipFactory(){} public static ShipFactory getInstance(){ if( itsInstance == null ) itsInstance = new ShipFactory(); return itsInstance; } public void setShipPrototype( Ship shipPrototype ) { this.itsShipPrototype = shipPrototype; } public Ship getNewShipInstance( String material, String name ){ Ship clone = (Ship)itsShipPrototype.clone(); clone.setMaterial( material ); clone.setName( name ); clone.setNumber( ++itsShipProduced ); return clone; } }