mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-03 07:13:02 +00:00
Commented factory method example.
This commit is contained in:
1 parent
427df4e165
commit
2038d69d92
4 files changed
+23
No files matched your search
@@ -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 )
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* The interface containing method for producing objects.
|
||||
*
|
||||
*/
|
||||
public interface Blacksmith {
|
||||
|
||||
Weapon manufactureWeapon(WeaponType weaponType);
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Concrete subclass for creating new objects.
|
||||
*
|
||||
*/
|
||||
public class ElfBlacksmith implements Blacksmith {
|
||||
|
||||
public Weapon manufactureWeapon(WeaponType weaponType) {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
* Concrete subclass for creating new objects.
|
||||
*
|
||||
*/
|
||||
public class OrcBlacksmith implements Blacksmith {
|
||||
|
||||
public Weapon manufactureWeapon(WeaponType weaponType) {
|
||||
|
||||
Reference in new issue
Block a user