blob: 54a27941ea1866e207c4b9acc4c4c9d6e2d5013f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
class fraction(n,d)
method n()
return self.n
end
method d()
return self.d
end
method times(f)
return fraction(self.n * f$n(), self.d * f$d())
end
method asString()
return self.n||"/"||self.d
end
method asReal()
return real(self.n) / self.d
end
initially
if self.d=0 then stop("fraction: denominator=0")
end
|