<span class="kwd">public</span> <span class="kwd">class</span> <span class="typ">ShapeFactory</span> <span class="pun">{</span>
<span class="com">//use getShape method to get object of type shape </span>
<span class="kwd">public</span> <span class="typ">Shape</span><span class="pln"> getShape</span><span class="pun">(</span><span class="typ">String</span><span class="pln"> shapeType</span><span class="pun">){</span>
<span class="kwd">if</span><span class="pun">(</span><span class="pln">shapeType </span><span class="pun">==</span> <span class="kwd">null</span><span class="pun">){</span>
<span class="kwd">return</span> <span class="kwd">null</span><span class="pun">;</span>
<span class="pun">}</span>
<span class="kwd">if</span><span class="pun">(</span><span class="pln">shapeType</span><span class="pun">.</span><span class="pln">equalsIgnoreCase</span><span class="pun">(</span><span class="str">"CIRCLE"</span><span class="pun">)){</span>
<span class="kwd">return</span> <span class="kwd">new</span> <span class="typ">Circle</span><span class="pun">();</span>
<span class="pun">}</span> <span class="kwd">else</span> <span class="kwd">if</span><span class="pun">(</span><span class="pln">shapeType</span><span class="pun">.</span><span class="pln">equalsIgnoreCase</span><span class="pun">(</span><span class="str">"RECTANGLE"</span><span class="pun">)){</span>
<span class="kwd">return</span> <span class="kwd">new</span> <span class="typ">Rectangle</span><span class="pun">();</span>
<span class="pun">}</span> <span class="kwd">else</span> <span class="kwd">if</span><span class="pun">(</span><span class="pln">shapeType</span><span class="pun">.</span><span class="pln">equalsIgnoreCase</span><span class="pun">(</span><span class="str">"SQUARE"</span><span class="pun">)){</span>
<span class="kwd">return</span> <span class="kwd">new</span> <span class="typ">Square</span><span class="pun">();</span>
<span class="pun">}</span>
<span class="kwd">return</span> <span class="kwd">null</span><span class="pun">;</span>
<span class="pun">}</span>
<span class="pun">}</span>