Created
December 4, 2020 18:11
-
-
Save matiasdim/64b52722b265a737dfd0cb6fc17c55a3 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 { | |
var width: Double | |
var height: Double | |
init(width: Double, height: Double) { | |
self.width = width | |
self.height = height | |
} | |
func area() -> Double { | |
return width * height | |
} | |
} | |
class Square: Rectangle { | |
// Some extra methods that Rectangle does not implement | |
} | |
let square = Square(width: 2, height: 3) // Is that an actual square? | |
let squareArea = square.area() | |
print(squareArea) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment