Skip to content

Instantly share code, notes, and snippets.

@ryanmr ryanmr/Cards.scala

Created Mar 19, 2016
Embed
What would you like to do?
def split():(Deck, Deck) = {
val s = size()
val h = s / 2
val d1 = new Deck()
val d2 = new Deck()
for (i <- 1 to s) {
getCard() match {
case Some(card) => {
if (i < h) {
d1.addCard(card)
} else {
d2.addCard(card)
}
}
case None => {} // nothing
}
}
return (d1, d2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.