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

19 lines
443 B
Kotlin
Raw Permalink Normal View History

2023-06-05 16:37:37 +03:00
package OOP.Java.lab_5
2023-06-07 15:38:48 +03:00
/**
* A class representing a punctuation mark following a word or a sentence.
*
* @property punctuationMark a [String] value of a punctuation mark.
*/
2023-06-05 16:37:37 +03:00
class Punctuation(var punctuationMark: String) {
init {
2023-06-07 15:38:48 +03:00
if (!"\\p{Punct}".toRegex().containsMatchIn(punctuationMark)) {
2023-06-05 16:37:37 +03:00
this.punctuationMark = ""
}
}
2023-06-05 17:11:49 +03:00
override fun toString(): String {
return punctuationMark
}
2023-06-05 16:37:37 +03:00
}