forked from idg10/prog-cs-8-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.cs
36 lines (31 loc) · 782 Bytes
/
Point.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
namespace Structs
{
public struct Point
{
private double _x;
private double _y;
public Point(double x, double y)
{
_x = x;
_y = y;
}
public double X => _x;
public double Y => _y;
public static bool operator ==(Point p1, Point p2)
{
return p1.X == p2.X && p1.Y == p2.Y;
}
public static bool operator !=(Point p1, Point p2)
{
return p1.X != p2.X || p1.Y != p2.Y;
}
public override bool Equals(object obj)
{
return obj is Point p2 && this.X == p2.X && this.Y == p2.Y;
}
public override int GetHashCode()
{
return (X, Y).GetHashCode();
}
}
}