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;
- //properties
- public int X
- {
- get
- {
- return this.xCoord;
- }
- set
- {
- if ((xCoord < 0) || (xCoord > 100))
- {
- throw new ArgumentOutOfRangeException("The value must be in the range [0..100]");
- }
- else
- {
- this.xCoord = value;
- }
- }
- }
- public int Y
- {
- get
- {
- return this.yCoord;
- }
- set
- {
- if ((yCoord < 0) || (yCoord > 100))
- {
- throw new ArgumentOutOfRangeException("The value must be in the range [0..100]");
- }
- else
- {
- this.yCoord = value;
- }
- }
- }
- }
- class Program
- {
- public static void Main()
- {
- Point p1 = new Point(1000, -1000);
- Console.WriteLine(p1.X);
- Console.WriteLine(p1.Y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement