Last active
February 19, 2017 19:28
-
-
Save vvviiimmm/02be9c719c4e85e52a59955acbb2bb7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Won't compile | |
| trait Shape { | |
| // vvv (hmm) | |
| def area(???): Double | |
| } | |
| case class Circle(radius: Double) | |
| case class Rectangle(width: Double, length: Double) | |
| class CircleShape extends Shape { | |
| override def area(circle: Circle) : Double = math.Pi * math.pow(circle.radius, 2) | |
| } | |
| class RectangleShape extends Shape { | |
| override def area(rectangle: Rectangle): Double = rectangle.width * rectangle.length | |
| } | |
| // vvv (but what about this?) | |
| def areaOf(shape: Shape): Double = shape.area(???) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment