Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CompanyHierarchy
  8. {
  9.  
  10. public abstract class Person : IPerson
  11. {
  12. private int id;
  13. private string firstName;
  14. private string lastName;
  15. public Person(int personID, string personFirstName, string personLastName)
  16. {
  17. this.ID = personID;
  18. this.FirstName = personFirstName;
  19. this.LastName = personLastName;
  20. }
  21. public int ID
  22. {
  23. get
  24. {
  25. return this.id;
  26. }
  27. set
  28. {
  29. if (value < 0)
  30. {
  31. throw new ArgumentOutOfRangeException("ID cannot be negative!");
  32. }
  33. this.id = value;
  34. }
  35. }
  36.  
  37. public string FirstName
  38. {
  39. get
  40. {
  41. return this.firstName;
  42. }
  43. set
  44. {
  45. if (String.IsNullOrEmpty(value))
  46. {
  47. throw new ArgumentNullException("First name cannot be empty!");
  48. }
  49. this.firstName = value;
  50. }
  51. }
  52.  
  53. public string LastName
  54. {
  55. get
  56. {
  57. return this.lastName;
  58. }
  59. set
  60. {
  61. if (String.IsNullOrEmpty(value))
  62. {
  63. throw new ArgumentNullException("Last name cannot be empty!");
  64. }
  65. this.lastName = value;
  66. }
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement