Пример #1
0
 public Hero(IHeroRepository repository, string name)
 {
     try
     {
         Id = repository.GetAll().LastOrDefault().Id + 1;
     }
     catch (ArgumentNullException)
     {
         Id = 1;
     }
     finally
     {
         Name           = name;
         Weapon         = CreationServices.GetRandomInt(1, 7);
         DateOfCreation = DateTime.Now;
     }
 }
Пример #2
0
 public Dragon(IDragonRepository repository)
 {
     try
     {
         Id = repository.GetAll().LastOrDefault().Id + 1;
     }
     catch (ArgumentNullException)
     {
         Id = 1;
     }
     finally
     {
         CreatedHealthPoints = CreationServices.GetRandomInt(80, 100);
         CurrentHealthPoints = CreatedHealthPoints;
         Name           = CreationServices.GetRandomString(CreationServices.GetRandomInt());
         DateOfCreation = DateTime.Now;
     }
 }