Commented factory method example.

This commit is contained in:
Ilkka Seppala 2014-08-31 08:29:50 +03:00
parent 427df4e165
commit 2038d69d92
4 changed files with 23 additions and 0 deletions

View File

@ -1,5 +1,13 @@
package com.iluwatar;
/**
*
* In Factory Method we have an interface (Blacksmith) with a
* method for creating objects (manufactureWeapon). The concrete
* subclasses (OrcBlacksmith, ElfBlacksmith) then override the
* method to produce objects of their liking.
*
*/
public class App
{
public static void main( String[] args )

View File

@ -1,5 +1,10 @@
package com.iluwatar;
/**
*
* The interface containing method for producing objects.
*
*/
public interface Blacksmith {
Weapon manufactureWeapon(WeaponType weaponType);

View File

@ -1,5 +1,10 @@
package com.iluwatar;
/**
*
* Concrete subclass for creating new objects.
*
*/
public class ElfBlacksmith implements Blacksmith {
public Weapon manufactureWeapon(WeaponType weaponType) {

View File

@ -1,5 +1,10 @@
package com.iluwatar;
/**
*
* Concrete subclass for creating new objects.
*
*/
public class OrcBlacksmith implements Blacksmith {
public Weapon manufactureWeapon(WeaponType weaponType) {