Created
March 4, 2015 18:05
-
-
Save robwhitaker/b03c9adaf99bca8e2c91 to your computer and use it in GitHub Desktop.
swift-lab6
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 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