Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Point
- {
- ////constructor
- //public Point(int xCoord, int yCoord)
- //{
- // this.X = xCoord;
- // this.Y = yCoord;
- //}
- //fields
- private int xCoord;
- private int yCoord;
- //property
- public int X
- {
- get
- {
- return this.xCoord;
- }
- set
- {
- this.xCoord = value;
- if ((xCoord < 0) || (xCoord > 100))
- {
- throw new ArgumentOutOfRangeException("The value must be in the range [0..100]");
- }
- }
- }
- public int Y
- {
- get
- {
- return this.yCoord;
- }
- set
- {
- this.yCoord = value;
- if ((yCoord < 0) || (yCoord > 100))
- {
- throw new ArgumentOutOfRangeException("The value must be in the range [0..100]");
- }
- }
- }
- }
- class Program
- {
- public static void Main()
- {
- Point p1 = new Point();
- p1.X = 1000;
- p1.Y = -1000;
- Console.WriteLine(p1.X);
- Console.WriteLine(p1.Y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement