Created
February 27, 2012 19:04
-
-
Save jacobh/1926292 to your computer and use it in GitHub Desktop.
Beginning Scala Exercise
This file contains hidden or 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
class Battery(ampsC: Int, mahC: Int) { | |
val amps: Float = ampsC | |
val mah: Float = mahC | |
def cRating() { | |
val result = amps * 1000 / mah | |
result | |
} | |
def flightTime() { | |
val result = 90 / (amps * 1000 / mah) | |
result | |
} | |
} |
This file contains hidden or 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
scala> var b = new Battery(15,1800) | |
b: Battery = Battery@a8960c5 | |
scala> b.cRating | |
scala> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment