Skip to content

Instantly share code, notes, and snippets.

@Adnan9011
Created May 23, 2022 02:34
Show Gist options
  • Save Adnan9011/7b1a5bdfd2997922682406e957f28390 to your computer and use it in GitHub Desktop.
Save Adnan9011/7b1a5bdfd2997922682406e957f28390 to your computer and use it in GitHub Desktop.
// 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