internal Potential(Square square, Group group, Number number,PotentialTypes potentialType) { this.Square = square; this.SquareGroup = group; this.Number = number; this.PotentialType = potentialType; }
void Square_NumberBecameUnavailable(Number number) { CheckPotentialSquare(number); }
/// <summary> /// Checks for potential square /// </summary> /// <param name="number"></param> void CheckPotentialSquare(Number number) { Square potentialSquare = GetPotentialSquare(number); //If there is a potential, raise an event to let Sudoku class to add this potential to the list if (potentialSquare != null) PotentialFound(new Potential(potentialSquare, this, number, PotentialTypes.Group)); }
internal Square GetPotentialSquare(Number number) { //If there is already a square which has this number, ignore this alert if (_Squares.Exists(s => s.Number.Equals(number))) return null; //Get the list of squares which are available var list = _Squares.Where(s => s.IsAvailable && s.AvailableNumbers.Contains(number)).ToList(); //If there is only one, set it as potential if (list.Count().Equals(1)) return list[0]; return null; }