Commented factory method example.
This commit is contained in:
parent
427df4e165
commit
2038d69d92
@ -1,5 +1,13 @@
|
|||||||
package com.iluwatar;
|
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 class App
|
||||||
{
|
{
|
||||||
public static void main( String[] args )
|
public static void main( String[] args )
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The interface containing method for producing objects.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface Blacksmith {
|
public interface Blacksmith {
|
||||||
|
|
||||||
Weapon manufactureWeapon(WeaponType weaponType);
|
Weapon manufactureWeapon(WeaponType weaponType);
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Concrete subclass for creating new objects.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ElfBlacksmith implements Blacksmith {
|
public class ElfBlacksmith implements Blacksmith {
|
||||||
|
|
||||||
public Weapon manufactureWeapon(WeaponType weaponType) {
|
public Weapon manufactureWeapon(WeaponType weaponType) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Concrete subclass for creating new objects.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class OrcBlacksmith implements Blacksmith {
|
public class OrcBlacksmith implements Blacksmith {
|
||||||
|
|
||||||
public Weapon manufactureWeapon(WeaponType weaponType) {
|
public Weapon manufactureWeapon(WeaponType weaponType) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user