Advertisement
hristo_bratanov

Untitled

Apr 26th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Figure
  5. {
  6.     private const double DimensionMinValue = 0;
  7.  
  8.     private double width;
  9.     private double height;
  10.  
  11.     public double Width
  12.     {
  13.         get
  14.         {
  15.             return this.width;
  16.         }
  17.         set
  18.         {
  19.             this.width = value;
  20.             if (IsValidDimension(value))
  21.             {
  22.                 this.width = value;
  23.             }
  24.             else
  25.             {
  26.                 throw new ArgumentOutOfRangeException("width", string.Format
  27.                     ("width should be between {0} and {1} inclusive.", DimensionMinValue, double.MaxValue));
  28.             }
  29.         }
  30.     }
  31.  
  32.     public double Height
  33.     {
  34.         get
  35.         {
  36.             return this.height;
  37.         }
  38.         set
  39.         {
  40.             if (IsValidDimension(value))
  41.             {
  42.                 this.height = value;
  43.             }
  44.             else
  45.             {
  46.                 throw new ArgumentOutOfRangeException("height", string.Format
  47.                     ("height should be between {0} and {1} inclusive.", DimensionMinValue, double.MaxValue));
  48.             }
  49.         }
  50.     }
  51.  
  52.     public Figure(double width, double height)
  53.     {
  54.         this.Width = width;
  55.         this.Height = height;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement