-
-
Save virendersran01/ba593da90b50277dcb8ccb5ac19a1947 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
enum class Assessment { | |
A, B, C, D, E, F | |
} |
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 CandidateEntity(val id: String, val fullName: String, val contactNumbers: Collection<PhoneNumberEntity> = mutableListOf(), val grade: Assessment?) { | |
init { | |
if (fullName.split(' ').size < 2) throw NotFullNameException() | |
} | |
fun addContactNumber(contactNumber: PhoneNumberEntity) { | |
(contactNumbers as MutableCollection).add(contactNumber) | |
} | |
} |
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 PhoneNumberEntity(val phoneNumber: String) { | |
init { | |
if (phoneNumber.matches(Regex("^\\+\\d{11}\$")).not()) | |
throw IncorrectPhoneNumberException() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment