Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Child : Person
- {
- public Child(string name, int age)
- : base(name, age)
- {
- }
- public override int Age
- {
- get
- {
- return base.Age;
- }
- set
- {
- if (!ValidateAge(value))
- {
- throw new ArgumentException("Child's age must be less than 15!");
- }
- base.Age = value;
- }
- }
- protected override bool ValidateAge(int age)
- {
- return age < 15;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement