added builder sample

This commit is contained in:
Ilkka Seppala
2014-08-09 22:38:07 +03:00
parent 959a1f63ba
commit a4b58fe06e
9 changed files with 272 additions and 0 deletions
@@ -0,0 +1,31 @@
package com.iluwatar;
import com.iluwatar.Hero.HeroBuilder;
public class App
{
public static void main( String[] args )
{
Hero mage = new HeroBuilder(Profession.MAGE, "Riobard")
.withHairColor(HairColor.BLACK)
.withWeapon(Weapon.DAGGER)
.build();
System.out.println(mage);
Hero warrior = new HeroBuilder(Profession.WARRIOR, "Amberjill")
.withHairColor(HairColor.BLOND)
.withHairType(HairType.LONG_CURLY)
.withArmor(Armor.CHAIN_MAIL)
.withWeapon(Weapon.SWORD)
.build();
System.out.println(warrior);
Hero thief = new HeroBuilder(Profession.THIEF, "Desmond")
.withHairType(HairType.BOLD)
.withWeapon(Weapon.BOW)
.build();
System.out.println(thief);
}
}