Skip to content

Instantly share code, notes, and snippets.

@robwhitaker
Created March 4, 2015 18:05
Show Gist options
  • Save robwhitaker/b03c9adaf99bca8e2c91 to your computer and use it in GitHub Desktop.
Save robwhitaker/b03c9adaf99bca8e2c91 to your computer and use it in GitHub Desktop.
swift-lab6
class Shape {
var title = "shape"
func area() -> Double {
return 0.0
}
func description() -> String {
return "I am a \(title). My area is \(area())."
}
}
class Square : Shape {
var sideLength = 0.0
override func area() -> Double {
return sideLength * sideLength
}
}
let shape = Shape()
let square = Square()
shape.area()
shape.description()
square.area()
square.description()
square.sideLength = 4
square.title = "SQUARE"
shape.area()
shape.description()
square.area()
square.description()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment