working to_s

This commit is contained in:
Dan Ballard 2011-08-26 08:26:55 -07:00
parent 7ae8e9cd81
commit 8e505715b2
1 changed files with 12 additions and 3 deletions

View File

@ -5,10 +5,19 @@ class Board
@board = Array.new(8) {|i| Array.new(8, '_')}
end
def print()
@board.each {|row| @row.each {|cell| print cell } puts "\n"}
def to_s()
str = ''
@board.each {|row|
row.each {|cell|
str += cell
}
str += "\n"
}
return str
end
end
b = Board.new()
b.print
puts b.to_s