#107 Factory Method example JavaDoc
This commit is contained in:
@ -2,13 +2,18 @@ package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* 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.
|
||||
* In Factory Method we have an interface ({@link Blacksmith}) with a method for
|
||||
* creating objects ({@link Blacksmith#manufactureWeapon}). The concrete subclasses
|
||||
* ({@link OrcBlacksmith}, {@link ElfBlacksmith}) then override the method to produce
|
||||
* objects of their liking.
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Blacksmith blacksmith;
|
||||
Weapon weapon;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* ElfWeapon
|
||||
*
|
||||
*/
|
||||
public class ElfWeapon implements Weapon {
|
||||
|
||||
private WeaponType weaponType;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* OrcWeapon
|
||||
*
|
||||
*/
|
||||
public class OrcWeapon implements Weapon {
|
||||
|
||||
private WeaponType weaponType;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* Weapon interface
|
||||
*
|
||||
*/
|
||||
public interface Weapon {
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.factory.method;
|
||||
|
||||
/**
|
||||
*
|
||||
* WeaponType enumeration
|
||||
*
|
||||
*/
|
||||
public enum WeaponType {
|
||||
|
||||
SHORT_SWORD("short sword"), SPEAR("spear"), AXE("axe"), UNDEFINED("");
|
||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
||||
|
||||
import com.iluwatar.factory.method.App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user