Method: Upwords::Board#initialize
- Defined in:
- lib/upwords/board.rb
#initialize(size = 10, max_height = 5) ⇒ Board
creates a 10 x 10 board
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/upwords/board.rb', line 7 def initialize(size=10, max_height=5) if !size.positive? raise ArgumentError, "Board size must be greater than zero!" else @size = size @max_height = max_height @min_word_length = 2 @grid = Hash.new do |h, (row, col)| if row < 0 || col < 0 || num_rows <= row || num_columns <= col raise IllegalMove, "#{row}, #{col} is out of bounds!" else h[[row, col]] = [] # Initialize with empty array end end end end |