-
Notifications
You must be signed in to change notification settings - Fork 2
/
CharProperties.scala
38 lines (31 loc) · 1.01 KB
/
CharProperties.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package charOperations
import charOperations.miscellaneous.ImportantConstants._
import utils.InputException
import utils.ExceptionMessages.DeprecatedSymbolInput
/**
* Contains functions, affecting char properties.
*
* Purity project by Daniil Tekunov.
*/
class CharProperties(val firstChar: Char) {
import CharProperties._
/**
* Checks, whether the char is vowel
*/
def isVowel: Boolean = {
if (Vowels.contains(firstChar.toLower)) true
else if (Consonants.contains(firstChar.toLower) || firstChar == '\0') false
else throw new InputException("\"isVowel\" " + DeprecatedSymbolInput)
}
/**
* Checks, whether the char is consonant
*/
def isConsonant: Boolean = {
if (Consonants.contains(firstChar.toLower)) true
else if (Vowels.contains(firstChar.toLower) || firstChar == '\0') false
else throw new InputException("\"isConsonant\" " + DeprecatedSymbolInput)
}
}
object CharProperties {
implicit def charToImplicitProps(a: Char): CharProperties = new CharProperties(a)
}