Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Point
- {
- public Point(int x, int y)
- {
- this.X = x;
- this.Y = y;
- }
- private int x;
- private int y;
- public int X {
- get
- {
- return this.x;
- }
- set
- {
- if ((x < 0) || (x > 100))
- {
- throw new ArgumentOutOfRangeException("Invalid value X. Must be between [0..100]!");
- }
- this.x = value;
- }
- }
- public int Y {
- get
- {
- return this.y;
- }
- set
- {
- if ((y < 0) || (y > 100))
- {
- throw new ArgumentOutOfRangeException("Invalid value Y. Must be between [0..100]!");
- }
- this.y = value;
- }
- }
- }
- class Program
- {
- static void Main()
- {
- Point p1 = new Point(-300, -5);
- Console.WriteLine(p1.X);
- //Point p2 = new Point(0, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement