Guest User

Child

a guest
Oct 30th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System;
  2.  
  3. class Child : Person
  4. {
  5.     public Child(string name, int age)
  6.         : base(name, age)
  7.     {
  8.         Age = age;
  9.     }
  10.  
  11.     public override int Age
  12.     {
  13.         get
  14.         {
  15.             return base.Age;
  16.         }
  17.         set
  18.         {
  19.             if (Age >= 15)
  20.             {
  21.                 throw new ArgumentException("Child's age must be less than 15!");
  22.             }
  23.  
  24.             Age = value;
  25.         }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment