|
@@ -5,19 +5,64 @@ package rocks.zipcode.io.quiz3.fundamentals;
|
5
|
5
|
*/
|
6
|
6
|
public class VowelUtils {
|
7
|
7
|
public static Boolean hasVowels(String word) {
|
8
|
|
- return null;
|
|
8
|
+ char [] chars = word.toCharArray();
|
|
9
|
+
|
|
10
|
+ for(int i=0;i <word.length();i++){
|
|
11
|
+ if(isVowel(chars[i])){
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+ return true;
|
|
15
|
+ }
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+ }
|
|
19
|
+
|
|
20
|
+ return false;
|
9
|
21
|
}
|
10
|
22
|
|
11
|
23
|
public static Integer getIndexOfFirstVowel(String word) {
|
12
|
|
- return null;
|
|
24
|
+ char [] chars = word.toCharArray();
|
|
25
|
+ Integer result = null;
|
|
26
|
+ for ( int i =0 ; i <chars.length ; i++) {
|
|
27
|
+
|
|
28
|
+ if (isVowel(chars[i])){
|
|
29
|
+
|
|
30
|
+ result = i;
|
|
31
|
+ break;
|
|
32
|
+ }
|
|
33
|
+
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+ return result ;
|
13
|
38
|
}
|
14
|
39
|
|
15
|
40
|
|
16
|
41
|
public static Boolean startsWithVowel(String word) {
|
17
|
|
- return null;
|
|
42
|
+
|
|
43
|
+ if((word.charAt(0) == 'A' ||
|
|
44
|
+ (word.charAt(0) == 'E') ||
|
|
45
|
+ (word.charAt(0) == 'I') ||
|
|
46
|
+ (word.charAt(0) == 'O') ||
|
|
47
|
+ (word.charAt(0) == 'U'))){
|
|
48
|
+ return true;
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ return false;
|
18
|
52
|
}
|
19
|
53
|
|
20
|
54
|
public static Boolean isVowel(Character character) {
|
21
|
|
- return null;
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+ if((Character.toLowerCase(character) == 'a') ||
|
|
58
|
+ (Character.toLowerCase(character )== 'e') ||
|
|
59
|
+ (Character.toLowerCase(character) == 'i') ||
|
|
60
|
+ (Character.toLowerCase(character) == 'o') ||
|
|
61
|
+ ( Character.toLowerCase(character) == 'u')) {
|
|
62
|
+ return true;
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+return false;
|
|
66
|
+
|
22
|
67
|
}
|
23
|
68
|
}
|