Created
May 23, 2022 02:34
-
-
Save Adnan9011/7b1a5bdfd2997922682406e957f28390 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
// 1 - Declare Interface | |
interface Person | |
// 2 - Declare Classes | |
class Women : Person | |
class Men : Person | |
// 3 - Declare Enum | |
enum class Gender {WOMEN , MEN} | |
// 4 - Declare Abstract class | |
abstract class PersonFactory { | |
companion object { | |
fun makePerson(gender: Gender): Person = | |
when (gender) { | |
Gender.WOMEN -> Women() | |
Gender.MEN -> Men() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment