-
-
Save 5AbhishekSaxena/c8e5d0ee44ea9cf2a15dc26e23301c76 to your computer and use it in GitHub Desktop.
This file contains 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 EducationBuilder { | |
private var school: String = "" | |
private var yearOfPassing: Int? = null | |
private var degree: String? = null // optional | |
fun setSchool(school: String): EducationBuilder = apply { | |
this.school = school | |
} | |
fun setYearOfPassing(yearOfPassing: Int?): EducationBuilder = apply { | |
this.yearOfPassing = yearOfPassing | |
} | |
fun setDegree(degree: String?): EducationBuilder = apply { | |
this.degree = degree | |
} | |
fun build(): Education { | |
return Education(school, yearOfPassing, degree) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment