Created
June 8, 2022 07:38
-
-
Save rockvivek/d7ce74f312d195cc9aaa84fb9f8d450b to your computer and use it in GitHub Desktop.
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 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