Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Animals
- {
- public abstract class Animal
- {
- private string name;
- private decimal age;
- public Gender gender { get; set; }
- public Animal(string name, decimal age, Gender gender)
- {
- this.Name = name;
- this.Age = age;
- this.gender = gender;
- }
- public string Name
- {
- get { return this.name; }
- set
- {
- if (String.IsNullOrEmpty(value))
- {
- throw new ArgumentNullException("Name cannot be empty!");
- }
- this.name = value;
- }
- }
- public decimal Age
- {
- get { return this.age; }
- set
- {
- if (value < 0)
- {
- throw new ArgumentOutOfRangeException("Age cannot be negative!")
- }
- this.age = value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement