Files
nodewars/NoduleConnection.cs
2026-05-30 01:05:14 +02:00

43 lines
869 B
C#

using System;
namespace NodeWar;
public class NoduleConnection
{
public Nodule A { get; set; }
public Nodule B { get; set; }
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
return obj.GetType() == GetType() && Equals((NoduleConnection)obj);
}
private bool Equals(NoduleConnection other)
{
return (Equals(A, other.A) && Equals(B, other.B))
|| (Equals(A, other.B) && Equals(B, other.A));
}
public override int GetHashCode()
{
var h1 = A?.GetHashCode() ?? 0;
var h2 = B?.GetHashCode() ?? 0;
return h1 ^ h2;
}
public static bool operator ==(NoduleConnection left, NoduleConnection right)
{
return Equals(left, right);
}
public static bool operator !=(NoduleConnection left, NoduleConnection right)
{
return !Equals(left, right);
}
}