Skip to content

Instantly share code, notes, and snippets.

@alexbevi
Last active August 29, 2015 14:02
Show Gist options
  • Save alexbevi/c3ea39f741cc3916b3d0 to your computer and use it in GitHub Desktop.
Save alexbevi/c3ea39f741cc3916b3d0 to your computer and use it in GitHub Desktop.
class Square: NamedShape {
var sideLength: Double
init(sideLength: Double, name: String) {
self.sideLength = sideLength
super.init(name: name)
numberOfSides = 4
}
func area() -> Double {
return sideLength * sideLength
}
override func simpleDescription() -> String {
return "A square with sides of length \(sideLength)."
}
}
let test = Square(sideLength: 5.2, name: "my test square")
test.area()
test.simpleDescription()
Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/fi/jEUH0.l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment