Map of buttons

Report a typo

You have a map with the names of buttons and corresponding font sizes and also a data class with default parameters. Write the body of the apply function so that your code could receive the name of a button from standard input, assign this value to the parameter text, and assign the corresponding value from map to the parameter textSize. After that, your code should print the new parameters to standard output like in the example. It's guaranteed that the input string will be contained in the map as key.

Sample Input 1:

Button

Sample Output 1:

New settings: TextField(text=Button, textSize=14, fontFamily=Roboto)
Write a program in Kotlin
data class TextField(
var text: String = "Hello!",
var textSize: Int = 12,
var fontFamily: String = "Roboto"
)

fun main() {
val textField = TextField()

val valuesMap = mapOf<String, Int>(
"Cancel" to 12,
"Button" to 14,
"Submit" to 13
)

textField
.apply {
// Write your code here
}
.also { println("New settings: $it") }
}
___

Create a free account to access the full topic