added factory method sample

This commit is contained in:
Ilkka Seppala
2014-08-10 10:07:38 +03:00
parent fbb9ebd46c
commit a9de898072
10 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.iluwatar;
public class App
{
public static void main( String[] args )
{
Blacksmith blacksmith;
Weapon weapon;
blacksmith = new OrcBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.AXE);
System.out.println(weapon);
blacksmith = new ElfBlacksmith();
weapon = blacksmith.manufactureWeapon(WeaponType.SHORT_SWORD);
System.out.println(weapon);
weapon = blacksmith.manufactureWeapon(WeaponType.SPEAR);
System.out.println(weapon);
}
}