Skip to content

Instantly share code, notes, and snippets.

@oinant
Created September 14, 2015 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oinant/d58721345407c4eecf28 to your computer and use it in GitHub Desktop.
Save oinant/d58721345407c4eecf28 to your computer and use it in GitHub Desktop.
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 ,
level:1,
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