Created
December 4, 2017 17:46
-
-
Save SiarheiFedartsou/2e4ed53aa47a8ece4b9f53a14a1dcb80 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
let rectangle = Rectangle(width: 42, height: 42) | |
let circle = Circle(radius: 42) | |
let squareVisitor = SquareShapeVisitor() | |
rectangle.accept(squareVisitor) | |
print(squareVisitor.square) // 1764.0 | |
circle.accept(squareVisitor) | |
print(squareVisitor.square) // 5541.77 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment