Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 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 Animals
  8. {
  9. public abstract class Animal
  10. {
  11. private string name;
  12. private decimal age;
  13.  
  14.  
  15. public Gender gender { get; set; }
  16.  
  17. public Animal(string name, decimal age, Gender gender)
  18. {
  19. this.Name = name;
  20. this.Age = age;
  21. this.gender = gender;
  22. }
  23.  
  24. public string Name
  25. {
  26. get { return this.name; }
  27. set
  28. {
  29. if (String.IsNullOrEmpty(value))
  30. {
  31. throw new ArgumentNullException("Name cannot be empty!");
  32. }
  33. this.name = value;
  34. }
  35. }
  36. public decimal Age
  37. {
  38. get { return this.age; }
  39. set
  40. {
  41. if (value < 0)
  42. {
  43. throw new ArgumentOutOfRangeException("Age cannot be negative!")
  44. }
  45. this.age = value;
  46. }
  47. }
  48.  
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement