17 lines
439 B
Kotlin
17 lines
439 B
Kotlin
package drills.drill03.exercise2
|
|
|
|
class PrintAgent(private val nodes: Array<Node>): AbstractAgent(){
|
|
private var index = 0
|
|
private val names = mutableListOf<String>()
|
|
|
|
override fun run() {
|
|
if (index < nodes.size) {
|
|
println("Insert your name:")
|
|
val name = readLine() ?: "no name"
|
|
names.add(name)
|
|
migrateTo(nodes[index++])
|
|
} else
|
|
println(names)
|
|
}
|
|
}
|