Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Created December 2, 2022 22:08
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 5AbhishekSaxena/ab4c00c2d95dd26740163317ec7bdfa6 to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/ab4c00c2d95dd26740163317ec7bdfa6 to your computer and use it in GitHub Desktop.
fun main() {
val rectangle = Rectangle()
rectangle.setHeight(5)
rectangle.setWidth(2)
val rectangleCheck = rectangle.area() == 10 // true
val square: Rectangle = Square()
square.setHeight(5) // width is also set to 5
square.setWidth(2) // height is also set to 2
val squareCheck = square.area() == 10 // false - not substitutable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment