Advertisement
desislava_topuzakova

клас Person

Apr 13th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using System;
  2. namespace DemoCapsulation
  3. {
  4. public class Person
  5. {
  6. //полета -> характеристики
  7. private string name;
  8. private int age;
  9. private double salary;
  10.  
  11. //get и set
  12. public string Name { get; set; }
  13. public int Age { get; set; }
  14. public double Salary { get; set; }
  15.  
  16. //конструктор
  17. public Person (string name, int age, double salary)
  18. {
  19. //нов празен обект
  20. this.Name = name;
  21. this.Age = age;
  22. }
  23.  
  24. //методи -> действия
  25. //1. увеличаване на заплата с 500
  26. public void IncreaseSalary ()
  27. {
  28. Salary += 500;
  29. }
  30.  
  31. //2. отпечатай възрастта
  32. public static void PrintAge()
  33. {
  34.  
  35. }
  36. }
  37. }
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement