Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 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 ClassLibrary
  8. {
  9. public class Bird : Animal
  10. {
  11. private int _speed;
  12.  
  13. public int Speed
  14. {
  15. get => _speed;
  16. set
  17. {
  18. if (value > 0 && value <= 100)
  19. _speed = value;
  20. else throw new ArgumentOutOfRangeException();
  21. }
  22. }
  23.  
  24. private Bird() { }
  25.  
  26. public Bird(string name, bool isTakingCare, int speed) : base(name, isTakingCare)
  27. {
  28. Speed = speed;
  29. }
  30.  
  31. public override string ToString()
  32. {
  33. return base.ToString() + $", Speed = {Speed}";
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement