public Student(string name, string email) { if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(email)) { throw new NullReferenceException(); } var extraction = new Extraction(); var mail = new Mail(); if (!mail.Validator(email)) { throw new WrongEmailException("Mail have wrong format"); } var Name = extraction.GetNameFromEmail(email); var Surname = extraction.GetSurnameFromEmail(email); if (name == (Name + " " + Surname)) { this.Name = name; this.Email = email; } else { throw new NotMatchException("Name doesn't match name, surname in Email"); } }
public Student(string email) { if (string.IsNullOrWhiteSpace(email)) { throw new NullReferenceException(); } var extraction = new Extraction(); var mail = new Mail(); if (!mail.Validator(email)) { throw new WrongEmailException("Mail have wrong format"); } this.Email = email; var Name = extraction.GetNameFromEmail(email); var Surname = extraction.GetSurnameFromEmail(email); this.Name = $"{Name} {Surname}"; }