Skip to content

Commit

Permalink
Changed BOARD_SIZE from a global constant to a constant within the Bo…
Browse files Browse the repository at this point in the history
…ard class. Added #valid_cell_number? to check if a number falls in the board's cell range
  • Loading branch information
lisahamm committed Mar 23, 2015
1 parent c64ca12 commit ee889e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/tic_tac_toe/board.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module TicTacToe
BOARD_SIZE = 3

class Board
attr_accessor :cells, :size

BOARD_SIZE = 3

def initialize(options={})
options = defaults.merge(options)
@size = options[:size]
Expand All @@ -22,6 +23,10 @@ def remove_mark(cell_number)
cells[cell_number].symbol = nil
end

def valid_cell_number?(cell_number)
(0..(size ** 2 - 1)).include?(cell_number)
end

def empty_cell?(cell_number)
cells[cell_number].symbol == nil
end
Expand Down

0 comments on commit ee889e6

Please sign in to comment.