Programming, Scala, Data Type, Abstraction, Introduction.
and resulting number are kept isolated within each object of the class itself and nothing else has access to it. Use the variable for gcd when constructing the numerator and denominator. class Rational(x: Int, y:Int) { private def gcd(a: Int, b: Int) : Int = if (b == 0) a else gcd(b, a % b) def