-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
画面表示用に外応するスート、11をJ(ジャック)のように変換するメソッドを追加した
- Loading branch information
1 parent
ac6a1a1
commit a60a041
Showing
1 changed file
with
21 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |