How about...
Language: Scala
class GoodLookingAssign {
private var theScore = Array(0.0, 0.0, 0.0);
def apply(i:Int): Double = theScore(i)
def update(i:Int, v:Double) = { theScore(i) = checkValid(v) }
def checkValid(x:Double): Double = {
var out = x
if (out < 0) { out = 0}
out
}
}
object ApplyGoodLooking {
def main(args: Array[String]) {
val g = new GoodLookingAssign()
println("g.score(0) = "+g(0))
g(0) = 4.4
println("g.score(0) = "+g(0))
}
}
__________________________________________________________
val signature:Option[String] = None
Edited 1 time(s). Last edit at 09/04/2011 11:45AM by Landei.