Advertisement
xxeell

Untitled

Jun 2nd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. struct Point
  2.     {
  3.         public int X { get; set; }
  4.         public int Y { get; set; }
  5.  
  6.         public Point(int x, int y)
  7.         {
  8.             this = new Point();
  9.             X = x;
  10.             Y = y;
  11.         }
  12.  
  13.         public Point(Point q)
  14.         {
  15.             this = new Point();
  16.             X = q.X;
  17.             Y = q.Y;
  18.         }
  19.  
  20.         public static Point operator +(Point x, Point y)
  21.         {
  22.             return new Point(x.X + y.X, x.Y + y.Y);
  23.         }
  24.  
  25.         public static Point operator -(Point x, Point y)
  26.         {
  27.             return new Point(x.X - y.X, x.Y - y.Y);
  28.         }
  29.  
  30.         public static bool operator ==(Point x, Point y)
  31.         {
  32.             return ((x.X == y.X) && (x.Y == y.Y));
  33.         }
  34.  
  35.         public static bool operator !=(Point x, Point y)
  36.         {
  37.             return !(x == y);
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement