Created
March 19, 2016 23:13
-
-
Save ryanmr/cf551582130842173d09 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
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