Advertisement
coasterka

Point.cs

Jul 19th, 2015
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. class Point
  4. {
  5.     public Point(int x, int y)
  6.     {
  7.         this.X = x;
  8.         this.Y = y;
  9.     }
  10.    
  11.     private int x;
  12.     private int y;
  13.  
  14.     public int X {
  15.         get
  16.         {
  17.             return this.x;
  18.         }
  19.         set
  20.         {
  21.             if ((x < 0) || (x > 100))
  22.             {
  23.                 throw new ArgumentOutOfRangeException("Invalid value X. Must be between [0..100]!");
  24.             }
  25.             this.x = value;
  26.         }
  27.     }
  28.  
  29.     public int Y {
  30.         get
  31.         {
  32.             return this.y;
  33.         }
  34.         set
  35.         {
  36.             if ((y < 0) || (y > 100))
  37.             {
  38.                 throw new ArgumentOutOfRangeException("Invalid value Y. Must be between [0..100]!");
  39.             }
  40.             this.y = value;
  41.         }
  42.     }    
  43. }
  44.  
  45. class Program
  46. {
  47.     static void Main()
  48.     {
  49.         Point p1 = new Point(-300, -5);
  50.         Console.WriteLine(p1.X);
  51.         //Point p2 = new Point(0, 0);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement