Skip to content

Instantly share code, notes, and snippets.

@davetron5000
Created August 6, 2009 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davetron5000/163542 to your computer and use it in GitHub Desktop.
Save davetron5000/163542 to your computer and use it in GitHub Desktop.
import java.util.Date
class MeterRead(val date:Date,rawUsage:Int,val contribution:Float) {
val usage = rawUsage / contribution
def +(added:Int) = new MeterRead(date,(usage + added).intValue,1.0F)
override def toString = "Read on " + date + ", usage " + usage
}
object Main extends Application {
val read = new MeterRead(new Date,10,0.5F)
val more = read + 10
println(read)
println(more)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment