Skip to content

Instantly share code, notes, and snippets.

@dbousamra
Created December 13, 2011 05:54
Show Gist options
  • Save dbousamra/1470811 to your computer and use it in GitHub Desktop.
Save dbousamra/1470811 to your computer and use it in GitHub Desktop.
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