Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement