I am making an OO twenty one game. I have a Card class and a Deck class, the deck is made up of card objects. When a player shows their hand I call the to_s method on a card object which I represent in ascii characters. This all works fine except that the players hand prints out one card on top of the other. Wondering how I would go about printing the whole hand side by side. I have searched online and cannot find anything other than to use print instead of puts, but that does not resolve my issue. Thank you in advance for any advice you may have.
class Card
attr_reader :value
def initialize(suit, value)
@suit = suit
@value = value
end
def to_s
"""
+-----+
|#{@value} |
| |
| #{@suit} |
| |
| #{@value}|
+-----+
"""
end
end
Sample output:
Your Hand:
+-----+
|Q |
| |
| C |
| |
| Q|
+-----+
+-----+
|K |
| |
| S |
| |
| K|
+-----+
Your total is 20