-- rational numbers class in Eiffel class RATIONAL creation make -- "creation means constructor" feature { RATIONAL } -- list of classes "features" are visible to -- {ANY} is same as public (same as Object in java) -- {NONE} is stronger than private -- {RATIONAL} same as private in Java/C++ num: integer; -- int num; dem: integer; feature { RATIONAL, RATS } make(n:integer; d:integer) is -- constructor require d > 0 -- raise exception otherwise do num := n; -- assignment is :=, equality is = dem := d; end; -- make invert is -- void invert(void) ... local temp: integer; do temp := num; num := dem; dem := temp; end; rateq(other: RATIONAL) : boolean is -- boolean rateq(RATIONAL other) do result := (num*other.dem) = (dem*other.num); -- result is keyword end; printrat is do io.put_integer(num); io.put_string("/"); io.put_integer(dem); end; end -- class RATIONAL