SHARE
TWEET

Untitled

a guest Aug 19th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interface Shape {
  2.   fun perimeter(): Double
  3.   fun area(): Double
  4.   fun diameter(): Double
  5. }
  6.  
  7. class Rectangle(val x: Double, val y: Double) : Shape {
  8.   override fun perimeter() = (x + y) * 2
  9.   override fun area() = x * y
  10.   override fun diameter() = Math.sqrt(x * x + y * y)
  11. }
  12.  
  13. class Circle(val radius: Double) : Shape {
  14.   override fun perimeter() = 2 * PI * radius
  15.   override fun area() = PI * radius * radius
  16.   override fun diameter() = 2 * radius
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top