Skip to content

Commit

Permalink
カード情報を連想配列ではなくCardクラスに切り出す。
Browse files Browse the repository at this point in the history
  • Loading branch information
paraizo2424 committed Jul 21, 2020
1 parent b1becfe commit 1f43eb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions card.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Card
SUITS = [:♠︎, :♣︎, :❤, :♦︎]

def initialize(suit, num)
@num = num
@suit = suit
end
end
14 changes: 7 additions & 7 deletions deck.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require_relative "card"

class Deck
SUITS = ["♠︎", "♣︎", "❤︎", "♦︎"]

attr_accessor :decks

def initialize
@decks = []
SUITS.each do |suit|

Card::SUITS.each do |suit|
(1..13).each do |num|
@decks << {suit: suit, num: num}
@decks << Card.new(suit, num)
end
end
end
end
end

0 comments on commit 1f43eb0

Please sign in to comment.