33 lines
723 B
C#
33 lines
723 B
C#
namespace AdventOfCode.Core.Shared
|
|
{
|
|
public class Node
|
|
{
|
|
public int X { get; set; }
|
|
public int Y { get; set; }
|
|
public char Char { get; set; }
|
|
public short Integer => (short)Char;
|
|
|
|
public Node() { }
|
|
|
|
public Node(int x, int y, char character)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
Char = character;
|
|
}
|
|
|
|
public Node(Node position) : this(position.X, position.Y, position.Char)
|
|
{ }
|
|
|
|
public int DistanceTo(Node other)
|
|
{
|
|
return Math.Abs(X - other.X) + Math.Abs(Y - other.Y);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"[{Y},{X}] {Char}";
|
|
}
|
|
}
|
|
}
|