Last active
September 19, 2021 04:43
-
-
Save alfianyusufabdullah/f4f452806f501385100ccf133fea1a4d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.Date | |
interface Product { | |
val name: String | |
} | |
interface FoodProduct: Product { | |
val expiredDate: Date | |
} | |
class Banana: FoodProduct { | |
override val name: String = "Sweet Banana" | |
override val expiredDate = Date() | |
} | |
class Shoes: Product { | |
override val name: String = "Black Shoes" | |
} | |
fun main() { | |
val banana = Banana() | |
println(banana.name) | |
println(banana.expiredDate) | |
val shoes = Shoes() | |
println(shoes.name) | |
} |
This file contains hidden or 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
import java.util.Date | |
interface Product { | |
val name: String | |
val expiredDate: Date | |
} | |
class Banana: Product { | |
override val name: String = "Sweet Banana" | |
override val expiredDate = Date() | |
} | |
class Shoes: Product { | |
override val name: String = "Air Jordan" | |
override val expiredDate = Date() /// Expired date? | |
} | |
fun main() { | |
val banana = Banana() | |
println(banana.name) | |
println(banana.expiredDate) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment