working to_s
This commit is contained in:
parent
7ae8e9cd81
commit
8e505715b2
15
checkers.rb
15
checkers.rb
|
@ -5,10 +5,19 @@ class Board
|
||||||
@board = Array.new(8) {|i| Array.new(8, '_')}
|
@board = Array.new(8) {|i| Array.new(8, '_')}
|
||||||
end
|
end
|
||||||
|
|
||||||
def print()
|
def to_s()
|
||||||
@board.each {|row| @row.each {|cell| print cell } puts "\n"}
|
str = ''
|
||||||
|
@board.each {|row|
|
||||||
|
row.each {|cell|
|
||||||
|
str += cell
|
||||||
|
}
|
||||||
|
str += "\n"
|
||||||
|
}
|
||||||
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
b = Board.new()
|
b = Board.new()
|
||||||
b.print
|
puts b.to_s
|
||||||
|
|
Loading…
Reference in New Issue