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, '_')}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue