home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / IDOL.LZH / FRACTION.IOL < prev    next >
Text File  |  1991-07-18  |  368b  |  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.