home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / BIPL.ZIP / IDOL.ZIP / FRACTION.IOL < prev    next >
Encoding:
Text File  |  1991-12-30  |  368 b   |  20 lines

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