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
| SingletonClass.doing() |
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
| object SingletonClass { | |
| fun doing() {} | |
| } |
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
| val womenPerson = PersonFactory.makePerson(Gender.WOMEN) | |
| val menPerson = PersonFactory.makePerson(Gender.MEN) |
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
| // 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 { |
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
| val firstPerson = Person.Builder( | |
| name = "Bob", //Necessary | |
| family = "Ras") //Necessary | |
| .age(32) //Optional | |
| .email("[email protected]") //Optional | |
| .phoneNumber("+19094XXX") //Optional | |
| .nationalCode("09640XXXXX") //Optional | |
| .create() //Create | |
| val secondPerson = Person.Builder( | |
| name = "Alis", //Necessary |
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
| class Person( | |
| val name:String, | |
| val family:String, | |
| val age:Int, | |
| val nationalCode: String?, | |
| val email: String?, | |
| val phoneNumber: String? | |
| ) { | |
| // 1 - Private constructor | |
| private constructor(builder: Builder) : this ( |
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
| val firstPerson = Person( | |
| name = "Bob", //Necessary | |
| family = "Ras", //Necessary | |
| age = 32, //Optional | |
| email = "[email protected]", //Optional | |
| phoneNumber = "+19094XXX", //Optional | |
| nationalCode = "09640XXXXX" //Optional | |
| ) | |
| val secondPerson = Person( | |
| name = "Alis", //Necessary |
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
| data class Person( | |
| val name:String, | |
| val family:String, | |
| val age:Int = 0, | |
| val nationalCode: String? = null, | |
| val email: String? = null, | |
| val phoneNumber: String? = null | |
| ) |