Last active
November 30, 2016 08:23
-
-
Save helloworldsmart/deb40baee10fbb825b085bee9b9a7eb1 to your computer and use it in GitHub Desktop.
drawGeometry
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
| enum Geometry: Int { | |
| case triangle = 3 | |
| case square = 4 | |
| case pentagon = 5 | |
| case hexagon = 6 | |
| } | |
| func drawGeometry(stepsLabel: Int, sides: Geometry) { | |
| let count = sides.rawValue | |
| let exteriorAngle = 360 / count | |
| for _ in 0..<count { | |
| move(steps: stepsLabel) | |
| rotate(degrees: exteriorAngle) | |
| } | |
| } | |
| func runDrawing() { | |
| drawGeometry(stepsLabel: 50, sides: Geometry.triangle) | |
| drawGeometry(stepsLabel: 50, sides: .pentagon) | |
| drawGeometry(stepsLabel: 50, sides: .hexagon) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment