Przejdź do treści

A simple implementation of fractions in Java and C++.


Status Production/Stable
Language Java, C++
License 3-clause BSD
Role Maintainer

Versions: Java, C++.

A simple implementation of fractions, used to learn OOP in Java and C++.

The Fraction class supports: * addition, subtraction, multiplication and division (via methods in Java and

System Message: ERROR/3 (<string>, line 9)

Unexpected indentation.
operator overloading in C++)

System Message: WARNING/2 (<string>, line 10)

Block quote ends without a blank line; unexpected unindent.
  • simplification (2/4 -> 1/2)
  • mixed numbers (eg. 5/2 == 2 1/2)

The Fraction class currently does not support: * comparisons * unit testing

The Fraction class was written in Java first and then rewritten in C++. It was a learning exercise to understand how to write object-oriented code in those two languages.

The class is documented in Javadoc and Doxygen (but the docs are not shipped as of now).