Skip to content

Instantly share code, notes, and snippets.

@DeepSky8
Created April 8, 2014 18:18
Show Gist options
  • Save DeepSky8/10166140 to your computer and use it in GitHub Desktop.
Save DeepSky8/10166140 to your computer and use it in GitHub Desktop.
Coin Flip game in infancy
object coinFlip {
val wager = "Great! How much do you want to wager?"
val leave = "Well, thanks for coming out today, partner."
val again = "I didn't quite catch that, sonny. You'll have to speak up."
val get = readLine()
def continue(p: String): String = p.toLowerCase match {
case y "yes" => wager
case n "no" => leave
case _ => again
}
def main(args: Array[String]): Unit = {
println("Welcome to Outback CoinFlip!")
println("In this game, you'll be given 500 credits, your 'stake.'")
println("You can bet those credits in increments of 25 on the outcome of Honest Freddy's coin flip.")
println("Yessir, you won't find a better, more forgiving betting game out there.")
println("Honest Freddy won't hold your past bets against you. Every time you bet, the slate will be wiped clean.")
println("Honest Freddy DOES have to earn a living, however. Each time you bet, you must bet at least 25 credits.")
println("You can increase your bet in increments of 25.")
println("This means you can bet 25, 50, 75, and 100 credits, up to as many credits as you have.")
println()
println("Each time you bet, you have a chance to DOUBLE your money!")
println("If you bet 25 credits, and you bet correctly, you will receive 50 CREDITS back from Honest Freddy!")
println("If you bet 200 credits, you will get back a whopping 400 CREDITS!")
println("Tell me partner, have you EVER played a game of chance with such good odds?")
println("I didn't think so. Now, are you ready to play? Type Yes or No.")
val go = readLine()
println(continue(go))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment