Last active
August 29, 2015 14:13
-
-
Save ostretsov/989c64f468c827f8ed92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rectangle(width: Int, height: Int) { | |
def getWidth: Int = width | |
def getHeight: Int = height | |
} | |
class Square(side: Int) extends Rectangle(side, side) { | |
def getSomething: Int = 1 | |
} | |
def area(rectangle: Rectangle): Int = { | |
rectangle.getHeight * rectangle.getWidth * rectangle.getSomething // it would't work! | |
} | |
val s = new Square(5) | |
println(area(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment