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 MasterMindGame(int MaxTurns, int RowLength) { this.RowLength = RowLength; this.MaxTurns = MaxTurns; this.HiddenRow = new MasterMindRow(RowLength); HiddenRow.Fill(); this.Rows = new MasterMindRow[MaxTurns]; for (int i = 0; i < MaxTurns; i++) { this.Rows[i] = new MasterMindRow(RowLength); } }
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); }