Skip to content

Commit

Permalink
画面表示用に外応するスート、11をJ(ジャック)のように変換するメソッドを追加した
Browse files Browse the repository at this point in the history
  • Loading branch information
paraizo2424 committed Jul 21, 2020
1 parent ac6a1a1 commit a60a041
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions card.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
class Card
SUITS = [:♠︎, :♣︎, :♡, :♢]
SUITS = [:spade, :heart, :diamond, :clover]

MARK = {
spade: "♠",
heart: "♡",
diamond: "♢",
clover: "♣",
1 => "A",
11 => "J",
12 => "Q",
13 => "K"
}

def initialize(suit, num)
@num = num
@suit = suit
end

def show
@suit.to_s + @num.to_s
corresponding_mark(@suit) + corresponding_mark(@num)
end

def corresponding_mark(sym)
if MARK[sym]
return MARK[sym]
else
return sym.to_s
end
end
end

0 comments on commit a60a041

Please sign in to comment.