Created
December 13, 2011 05:54
-
-
Save dbousamra/1470811 to your computer and use it in GitHub Desktop.
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
package horses | |
import Suit.Suit | |
import Rank.Rank | |
import scala.collection.mutable.ArrayBuffer | |
object Suit extends Enumeration { | |
type Suit = Value | |
val Clubs, Diamonds, Hearts, Spades = Value | |
} | |
object Rank extends Enumeration { | |
type Rank = Value | |
val Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace = Value | |
} | |
case class Card(rank: Rank, suit: Suit) {} | |
case class Deck() { | |
var cards: Seq[Card] = { | |
val deck = ArrayBuffer.empty[Card] | |
Suit.values foreach (suit => { | |
for (rank <- Rank.values) { | |
deck += Card(rank, suit) | |
} | |
}) | |
deck | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment