Advertisement
Guest User

Untitled

a guest
Dec 25th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2.  
  3. class Point
  4. {
  5. ////constructor
  6. //public Point(int xCoord, int yCoord)
  7. //{
  8. // this.X = xCoord;
  9. // this.Y = yCoord;
  10. //}
  11. //fields
  12. private int xCoord;
  13. private int yCoord;
  14.  
  15. //property
  16. public int X
  17. {
  18. get
  19. {
  20. return this.xCoord;
  21. }
  22. set
  23. {
  24. this.xCoord = value;
  25. if ((xCoord < 0) || (xCoord > 100))
  26. {
  27. throw new ArgumentOutOfRangeException("The value must be in the range [0..100]");
  28. }
  29. }
  30. }
  31. public int Y
  32. {
  33. get
  34. {
  35. return this.yCoord;
  36. }
  37. set
  38. {
  39. this.yCoord = value;
  40. if ((yCoord < 0) || (yCoord > 100))
  41. {
  42. throw new ArgumentOutOfRangeException("The value must be in the range [0..100]");
  43. }
  44. }
  45. }
  46. }
  47. class Program
  48. {
  49. public static void Main()
  50. {
  51. Point p1 = new Point();
  52. p1.X = 1000;
  53. p1.Y = -1000;
  54.  
  55. Console.WriteLine(p1.X);
  56. Console.WriteLine(p1.Y);
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement