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