Advertisement
desislava_topuzakova

Dog.cs

Jul 7th, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace AlgorithmsRetakeExam
  6. {
  7. public class Dog
  8. {
  9. private string name;
  10. private int age;
  11.  
  12. public Dog()
  13. {
  14.  
  15. }
  16.  
  17. public Dog(string name, int age)
  18. {
  19. Name = name;
  20. Age = age;
  21. }
  22.  
  23. public string Name
  24. {
  25. get
  26. {
  27. return name;
  28. }
  29. set
  30. {
  31. name = value;
  32. }
  33. }
  34. public int Age
  35. {
  36. get
  37. {
  38. return age;
  39. }
  40. set
  41. {
  42. age = value;
  43. }
  44. }
  45.  
  46. public override string ToString()
  47. {
  48. return $"Dog {Name} is {Age} years old.";
  49. }
  50.  
  51. }
  52. }
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement