-
-
Save oinant/d58721345407c4eecf28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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