OOP_IO-2x_2023-mirror/Java/lab_5/Word.kt

13 lines
365 B
Kotlin
Raw Normal View History

2023-06-05 16:37:37 +03:00
package OOP.Java.lab_5
class Word(var letters: Array<Letter>) {
override fun toString(): String {
val wordString = StringBuilder()
this.letters.forEach { wordString.append(it) }
return wordString.toString()
}
constructor(
word: String
2023-06-05 17:11:49 +03:00
) : this((word.toCharArray().map { letter -> Letter(letter) }).toTypedArray())
2023-06-05 16:37:37 +03:00
}