Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Created June 5, 2023 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 5AbhishekSaxena/c8e5d0ee44ea9cf2a15dc26e23301c76 to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/c8e5d0ee44ea9cf2a15dc26e23301c76 to your computer and use it in GitHub Desktop.
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