Sha256: 9f895b75070702ecf093195e86cc3ed602320837271dae4ce1b45ea72f6251b7
Contents?: true
Size: 887 Bytes
Versions: 1
Compression:
Stored size: 887 Bytes
Contents
module MM class Pegs attr_reader :collection_of_pegs #collection_of_pegs is a multi-dimensional array def initialize(args) @collection_of_pegs = args.fetch(:collection_of_pegs) end def retrieve_peg(row, col) if row >= number_of_rows || col >= number_of_cols return nil else return collection_of_pegs[row][col] end end def current_row(number_of_turns_taken) collection_of_pegs[number_of_turns_taken] end def display_values # reversed so that game appears to be filling itself in from top to bottom collection_of_pegs.reverse.map do |row| row.map do |peg| peg.display_value end end end private def number_of_rows collection_of_pegs.length end def number_of_cols collection_of_pegs[0].length end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
games_bfox-0.4.0 | lib/games/mastermind/pegs.rb |