-
Notifications
You must be signed in to change notification settings - Fork 0
/
Location.cs
42 lines (40 loc) · 1.05 KB
/
Location.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
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game
{
// location class which holds x,y coordinates
public class Loc
{
public int x;
public int y;
// set default location for all elements
public Loc()
{
x = 0;
y = 0;
}
// set the location
public void Is(int first, int second)
{
x = first;
y = second;
}
// pretty print function for debugging purposes
public void Print()
{
Console.Write("(" + x + ", " + y + ")");
}
// overload equality operators to test for equality
public static bool operator ==(Loc obj1, Loc obj2)
{
return (obj1.x == obj2.x && obj1.y == obj2.y);
}
public static bool operator !=(Loc obj1, Loc obj2)
{
return !(obj1.x == obj2.x && obj1.y == obj2.y);
}
}
}