Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Zad2

class Euro(eu: Int, cen: Int = 0) {
  var euro: Int = eu
  var cents: Int = cen
  var inCents: Int = (euro * 100) + cents

  def +(x: Euro): Unit = {
    val a = x.cents + cents
    val b = x.euro + euro + (a / 100)
    cents = a % 100
    euro = b
  }

  def *(x: Int): Unit = {
    val a = cents*x
    val b = euro*x + (a/100)
    cents = a % 100
    euro = b
  }
}

object Euro {
  def fromCents(cents: Int): Euro = {
    new Euro(cents / 100, cents % 100)
  }
}

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("hellooo")
  }

  def f(e: Euro): Unit = {
    println(e.euro + "." + e.cents)
  }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.