Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open class Point2D(
- val x: Int,
- val y: Int
- ) {
- override fun hashCode(): Int = x + y
- override fun equals(other: Any?): Boolean =
- other is Point2D &&
- other.x == x &&
- other.y == y
- }
- class Point3D(
- x: Int,
- y: Int,
- val z: Int
- ) : Point2D(x, y) {
- override fun hashCode(): Int = super.hashCode() + z
- override fun equals(other: Any?): Boolean =
- super.equals(other) &&
- other is Point3D &&
- other.z == z
- }
Advertisement
Add Comment
Please, Sign In to add comment