From 2ddeaab94fca62d1e27576252d392122d9617788 Mon Sep 17 00:00:00 2001 From: Rhinemann Date: Mon, 5 Jun 2023 16:37:37 +0300 Subject: [PATCH] Lab 5, started. --- Java/lab_5/Letter.kt | 11 +++++++++++ Java/lab_5/Punctuation.kt | 11 +++++++++++ Java/lab_5/Sentence.kt | 4 ++++ Java/lab_5/Word.kt | 13 +++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 Java/lab_5/Letter.kt create mode 100644 Java/lab_5/Punctuation.kt create mode 100644 Java/lab_5/Sentence.kt create mode 100644 Java/lab_5/Word.kt diff --git a/Java/lab_5/Letter.kt b/Java/lab_5/Letter.kt new file mode 100644 index 0000000..fd34936 --- /dev/null +++ b/Java/lab_5/Letter.kt @@ -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) + } +} \ No newline at end of file diff --git a/Java/lab_5/Punctuation.kt b/Java/lab_5/Punctuation.kt new file mode 100644 index 0000000..fb4a96c --- /dev/null +++ b/Java/lab_5/Punctuation.kt @@ -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 = "" + } + } +} \ No newline at end of file diff --git a/Java/lab_5/Sentence.kt b/Java/lab_5/Sentence.kt new file mode 100644 index 0000000..5f52977 --- /dev/null +++ b/Java/lab_5/Sentence.kt @@ -0,0 +1,4 @@ +package OOP.Java.lab_5 + +class Sentence { +} \ No newline at end of file diff --git a/Java/lab_5/Word.kt b/Java/lab_5/Word.kt new file mode 100644 index 0000000..beb3ee4 --- /dev/null +++ b/Java/lab_5/Word.kt @@ -0,0 +1,13 @@ +package OOP.Java.lab_5 + +class Word(var letters: Array) { + 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()) +} \ No newline at end of file