Last active
July 8, 2020 07:23
-
-
Save macieknajbar/2a63e6cccb7af5ec1f3a549cb0c2be21 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