Skip to content

Instantly share code, notes, and snippets.

@hudinwal
Last active October 20, 2016 18:27
Show Gist options
  • Save hudinwal/d9a21ebcdc112680c231f2a8c3e27a62 to your computer and use it in GitHub Desktop.
Save hudinwal/d9a21ebcdc112680c231f2a8c3e27a62 to your computer and use it in GitHub Desktop.
class Shape {
var name: String
var sides : Int
init(sides:Int, named: String) {
self.sides = sides
self.name = named
printShapeDescription()
}
func printShapeDescription() {
print("Shape Name :\(self.name)")
print("Sides :\(self.sides)")
}
}
class Triangle: Shape {
var hypotenuse: Int
init(hypotenuse:Int) {
self.hypotenuse = hypotenuse
super.init(sides: 3, named: "Triangle")
}
override func printShapeDescription() {
super.printShapeDescription()
print("Hypotenuse :\(self.hypotenuse)")
}
}
let triangle = Triangle(hypotenuse: 12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment