|
@@ -4,20 +4,45 @@ package rocks.zipcode.io.quiz3.fundamentals;
|
4
|
4
|
* @author leon on 09/12/2018.
|
5
|
5
|
*/
|
6
|
6
|
public class VowelUtils {
|
7
|
|
- public static Boolean hasVowels(String word) {
|
8
|
|
- return null;
|
|
7
|
+ public static Boolean hasVowels(String str) {
|
|
8
|
+
|
|
9
|
+ for (int i = 0; i < str.length() ; i++) {
|
|
10
|
+ if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i'
|
|
11
|
+ || str.charAt(i) == 'o' || str.charAt(i) == 'u' || str.charAt(i) == 'A' ||
|
|
12
|
+ str.charAt(i) == 'E' || str.charAt(i) == 'I' || str.charAt(i) == 'O'
|
|
13
|
+ || str.charAt(i) == 'U')
|
|
14
|
+ return true;
|
|
15
|
+ }
|
|
16
|
+ return false;
|
9
|
17
|
}
|
10
|
18
|
|
11
|
|
- public static Integer getIndexOfFirstVowel(String word) {
|
|
19
|
+ public static Integer getIndexOfFirstVowel(String str) {
|
|
20
|
+
|
|
21
|
+ for (int i = 0; i < str.length() ; i++) {
|
|
22
|
+ if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i'
|
|
23
|
+ || str.charAt(i) =='o' || str.charAt(i) == 'u' || str.charAt(i) == 'A' ||
|
|
24
|
+ str.charAt(i) == 'E' || str.charAt(i) == 'I' || str.charAt(i) == 'O'
|
|
25
|
+ || str.charAt(i) == 'U')
|
|
26
|
+ return i;
|
|
27
|
+ }
|
12
|
28
|
return null;
|
13
|
29
|
}
|
14
|
30
|
|
15
|
31
|
|
16
|
|
- public static Boolean startsWithVowel(String word) {
|
17
|
|
- return null;
|
|
32
|
+ public static Boolean startsWithVowel(String str) {
|
|
33
|
+ return (str.startsWith("a")||str.startsWith("e")||str.startsWith("i")||
|
|
34
|
+ str.startsWith("o")||str.startsWith("u")||str.startsWith("A")||
|
|
35
|
+ str.startsWith("E")||str.startsWith("I")||str.startsWith("O")||str.startsWith("U"));
|
18
|
36
|
}
|
19
|
37
|
|
20
|
38
|
public static Boolean isVowel(Character character) {
|
21
|
|
- return null;
|
|
39
|
+ if (character == 'a' || character == 'e' || character == 'i'
|
|
40
|
+ || character =='o' || character == 'u' ||character == 'A' ||
|
|
41
|
+ character == 'E' || character == 'I' || character == 'O'
|
|
42
|
+ || character == 'U')
|
|
43
|
+ return true;
|
|
44
|
+ return false;
|
|
45
|
+ }
|
|
46
|
+
|
22
|
47
|
}
|
23
|
|
-}
|
|
48
|
+
|