mitko2204

Sttudent

Feb 18th, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Mankind11b
  7. {
  8. public class Student : Human
  9. {
  10. private string facultyNumber;
  11.  
  12. public Student(string firstName, string lastName, string facultyNumber) : base(firstName, lastName)
  13. {
  14. FacultyNumber = facultyNumber;
  15. }
  16.  
  17. public string FacultyNumber
  18. {
  19. get { return facultyNumber; }
  20. set {
  21. if (!(value.Length >= 5 && value.Length <= 10))
  22. {
  23. throw new ArgumentException("Invalid faculty number!");
  24. }
  25. if (!value.All(Char.IsLetterOrDigit))
  26. {
  27. throw new ArgumentException("Invalid faculty number!");
  28. }
  29. facultyNumber = value;
  30. }
  31. }
  32.  
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment