Lab 5, started.

This commit is contained in:
Rhinemann 2023-06-05 16:37:37 +03:00
parent 2b8f88a45f
commit 2ddeaab94f
4 changed files with 39 additions and 0 deletions

11
Java/lab_5/Letter.kt Normal file
View File

@ -0,0 +1,11 @@
package OOP.Java.lab_5
class Letter(val character: Char) {
override fun toString(): String {
return this.character.toString()
}
fun equals(letter: Letter, ignoreCase: Boolean): Boolean {
return this.character.toString().equals(letter.toString(), ignoreCase)
}
}

11
Java/lab_5/Punctuation.kt Normal file
View File

@ -0,0 +1,11 @@
package OOP.Java.lab_5
class Punctuation(var punctuationMark: String) {
private val punctuationMarkOptions: Regex = Regex("\\p{Punct}")
init {
if (!punctuationMarkOptions.containsMatchIn(punctuationMark)){
this.punctuationMark = ""
}
}
}

4
Java/lab_5/Sentence.kt Normal file
View File

@ -0,0 +1,4 @@
package OOP.Java.lab_5
class Sentence {
}

13
Java/lab_5/Word.kt Normal file
View File

@ -0,0 +1,13 @@
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
) : this((word.toCharArray().map { n -> Letter(n) }).toTypedArray())
}