Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created December 24, 2020 13:08
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 PatilShreyas/009c36df4eb7e6d45580500cb453c211 to your computer and use it in GitHub Desktop.
Save PatilShreyas/009c36df4eb7e6d45580500cb453c211 to your computer and use it in GitHub Desktop.
data class Sprint(val todoTasks: Int, val doneTasks: Int)
fun main() {
val sprint1 = Sprint(51, 20)
val sprint2 = Sprint(30, 40)
val totalTodoTasks = sprint1.todoTasks + sprint2.todoTasks // 51 + 30
val totalDoneTasks = sprint1.doneTasks + sprint2.doneTasks // 20 + 40
val newSprint = Sprint(totalTodoTasks, totalDoneTasks)
}
data class Sprint(val todoTasks: Int, val doneTasks: Int) {
operator fun plus(other: Sprint): Sprint {
return Sprint(todoTasks + other.todoTasks, doneTasks + other.doneTasks)
}
}
fun main() {
val sprint1 = Sprint(51, 20)
val sprint2 = Sprint(30, 40)
val newSprint = sprint1 + sprint2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment