Lab 5, progress.

This commit is contained in:
Rhinemann 2023-06-05 17:11:49 +03:00
parent 2ddeaab94f
commit 46d339f31e
3 changed files with 14 additions and 2 deletions

View File

@ -8,4 +8,8 @@ class Punctuation(var punctuationMark: String) {
this.punctuationMark = ""
}
}
override fun toString(): String {
return punctuationMark
}
}

View File

@ -1,4 +1,12 @@
package OOP.Java.lab_5
class Sentence {
class Sentence(sentenceString: String) {
init {
var split = sentenceString.split("(\\p{Punct}? )|(\\p{Punct})".toRegex())
var punctuation: Array<Punctuation> = sentenceString.split(" ").map { word -> Punctuation(word.last().toString()) }.toTypedArray()
for (elem in split) {
println(elem)
}
print(split)
}
}

View File

@ -9,5 +9,5 @@ class Word(var letters: Array<Letter>) {
}
constructor(
word: String
) : this((word.toCharArray().map { n -> Letter(n) }).toTypedArray())
) : this((word.toCharArray().map { letter -> Letter(letter) }).toTypedArray())
}