Skip to content

Instantly share code, notes, and snippets.

@Dglgmut
Created August 13, 2013 00:59
Show Gist options
  • Save Dglgmut/6216868 to your computer and use it in GitHub Desktop.
Save Dglgmut/6216868 to your computer and use it in GitHub Desktop.
class Coins(coinType: Symbol) {
def value: Double = coinTypesDictionary(coinType)
def toOneDollar: Double = 1.0 / this.value
}
object Coins{
private val coinTypesDictionary = Map[Symbol, Double]('penny -> 0.01, 'nickel -> 0.05, 'dime -> 0.10, 'quarter -> 0.25 )
def coinTypes: Iterable[Symbol] = coinTypesDictionary.keys
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment