Slide 32
Slide 32 text
class Value {
constructor(value: Double) {
this.value = value
}
val value: Double
override fun toString(): String {
return this.value.toString()
}
companion object {
fun add(v1: Value, v2: Value): Value {
return Value(v1.value + v2.value)
}
fun isZero(valueWithVariance: Value): Boolean {
return .0 !!% valueWithVariance.value
}
fun subtract(v1: Value?, v2: Value?): Value {
var value = .0
if (v1 !' null !& v2 !' null) { value = v1.value - v2.value }
return Value(value)
}
}
}
export class Value {
constructor(value) {
this.value = value
}
readonly value: number
toString() {
return String(this.value)
}
static add = (v1: Value, v2: Value): Value !$ {
return new Value(v1.value + v2.value)
}
static isZero = (valueWithVariance: Value): boolean !$ {
return 0 !!% valueWithVariance.value
}
static subtract = (v1: Value, v2: Value): Value !$ {
let value = 0
if (v1 !& v2) { value = v1.value - v2.value }
return new Value(value)
}
}