public MasterMindResult CompareWithSecretRow(MasterMindRow SecretRow) { int ColorMatch = 0; int PosMatch = 0; Color[] RowToCompare = (Color[])SecretRow.GetRow().Clone(); for (int i = 0; i < colors.Length; i++) { if ((SecretRow.GetColor(i) == GetColor(i))) { PosMatch++; } for (int r = 0; r < colors.Length; r++) { if (ColorInArray(RowToCompare, GetColor(i))) { ColorMatch++; RemoveColorInArray(RowToCompare, GetColor(i)); } } } return(new MasterMindResult(ColorMatch, PosMatch)); }
public override bool Equals(object obj) { MasterMindRow OtherRow = (MasterMindRow)obj; for (int i = 0; i < colors.Length; i++) { if (OtherRow.GetColor(i) != GetColor(i)) { return(false); } } return(true); }