desislava_topuzakova

Person

May 6th, 2021
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Arrays
  6. {
  7. class Person
  8. {
  9. //полета -> характеристики
  10. private string firstName;
  11. private string lastName;
  12. private int age;
  13. private double salary;
  14.  
  15.  
  16. public Person ()
  17. {
  18.  
  19. }
  20.  
  21. public string FirstName
  22. {
  23. get { return this.firstName; }
  24. set
  25. {
  26. if (value.Length < 3)
  27. {
  28. throw new ArgumentException("Name must be over 3 characters");
  29. }
  30. this.firstName = value;
  31. }
  32. }
  33.  
  34. public string LastName
  35. {
  36. get { return this.lastName; }
  37. set
  38. {
  39. if (value.Length < 3)
  40. {
  41. throw new ArgumentException("Name must be over 3 characters!");
  42. }
  43. this.lastName = value;
  44. }
  45. }
  46.  
  47. public int Age
  48. {
  49. get { return this.age; }
  50. set
  51. {
  52. if(value <= 0)
  53. {
  54. throw new ArgumentException("Age cannot be negative number!");
  55. }
  56. this.age = value;
  57. }
  58. }
  59.  
  60. public double Salary
  61. {
  62. get { return this.salary; }
  63. set
  64. {
  65. if (value < 460)
  66. {
  67. throw new ArgumentException("Salary has to be over 460!");
  68. }
  69. this.salary = value;
  70. }
  71. }
  72. }
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment