L
L
LoftGun2021-03-14 13:03:30
Kotlin
LoftGun, 2021-03-14 13:03:30

Passing a value from a function to another Kotlin class?

Initially, the calendar shows a random date. It is necessary to implement the printing of the current date: select it and print the day, month and year, separated by a space.

class Calendar(var day: String, var month: String, var year: String) {
    fun selectCurrentDay() {
        day = "13"
        month = "03"
        year = "2021"
    }
}

fun createCalendar() =
    Calendar("13", "03", "2021")

fun main() {
    val calendar = createCalendar()

}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question