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

23 lines
715 B
Kotlin
Raw 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 single letter in a word.
*
* @property character a character value of a Letter.
*/
class Letter(private val character: Char) {
2023-06-05 16:37:37 +03:00
override fun toString(): String {
return this.character.toString()
}
2023-06-07 15:38:48 +03:00
/**
* Indicates whether the two objects of class Letter are "equal".
*
* @param letter a letter to compare.
* @param ignoreCase if set to "true" will ignore the case of Letters compared.
* @return "true" if letters are equal and "false" if they aren't.
*/
fun letterEquals(letter: Letter, ignoreCase: Boolean): Boolean {
2023-06-05 16:37:37 +03:00
return this.character.toString().equals(letter.toString(), ignoreCase)
}
}