Skip to content

Instantly share code, notes, and snippets.

Created Sep 14, 2015
What would you like to do?
namespace Blog.RolePlayingGame.Core
public class HeroBuilder
private HeroClass _class;
public HeroBuilder OfWarriorClass()
_class = HeroClass.Warrior;
return this;
public Hero Create()
if( IsClassNotSettled())
throw new BuildingHeroWithoutClassAttempException();
return new Hero(@class: _class,
name: _name ,
health: _health,
strength: 0,
spirit: 0,
speed: 0);
public class BuildingHeroWithoutClassAttempException : Exception
public BuildingHeroWithoutClassAttempException() : base ("Cannot creating an hero without class") { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment