public void Mark(int drawnNumber) { var match = BingoSpots.FirstOrDefault(x => x.Value == drawnNumber); if (match != null) { match.Marked = true; } }
public bool Evaluate() { for (var i = 0; i < 5; i++) { var bingoRow = BingoSpots.Count(x => x.X == i && x.Marked) == 5; var bingoColumn = BingoSpots.Count(x => x.Y == i && x.Marked) == 5; if (bingoColumn || bingoRow) { return(true); } } return(false); }
public BingoBoard(List <string> rows) { for (var i = 0; i < rows.Count; i++) { var row = rows[i].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList(); for (var j = 0; j < row.Count; j++) { BingoSpots.Add( new BingoSpot { X = j, Y = i, Value = int.Parse(row[j]), Marked = false } ); } } }