Skip to content

Instantly share code, notes, and snippets.

@virendersran01
Forked from macieknajbar/Assessment.kt
Created July 8, 2020 07:23
Show Gist options
  • Save virendersran01/ba593da90b50277dcb8ccb5ac19a1947 to your computer and use it in GitHub Desktop.
Save virendersran01/ba593da90b50277dcb8ccb5ac19a1947 to your computer and use it in GitHub Desktop.
enum class Assessment {
A, B, C, D, E, F
}
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)
}
}
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