Skip to content

Instantly share code, notes, and snippets.

@rockvivek
Created June 8, 2022 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rockvivek/d7ce74f312d195cc9aaa84fb9f8d450b to your computer and use it in GitHub Desktop.
Save rockvivek/d7ce74f312d195cc9aaa84fb9f8d450b to your computer and use it in GitHub Desktop.
class Rectangle{
let height: Double
let width: Double
init(height: Double, width: Double) {
self.height = height
self.width = width
}
func calculateArea() -> Double{
return width * height
}
}
class MeasureArea {
func area(obj: Rectangle) -> Double{
return obj.calculateArea()
}
}
let measureAreaObj = MeasureArea()
let rectObj = Rectangle(height: 5.0, width: 7.0)
print("Area of rectangle is: \(measureAreaObj.area(obj: rectObj))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment