WordSet VowelDivide WordSet w1 new WordSet WordSet w2 new WordSet w1 h

 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
WordSet [] VowelDivide() {
WordSet w1 = new WordSet();
WordSet w2 = new WordSet();
w1.head = null;
w2.head = null;
Elem p1 = null;
Elem p2 = null;
Elem p = head;
String vowels = "aeiouyаоэиуыеёюя";
int v = 0;
int c = 0;
while (p != null) {
boolean vowel = false;
String word = p.getValue();
String word1 = word.toLowerCase();
for (int i = 0; i < vowels.length() && !vowel; i++) {
if (word1.charAt(0) == vowels.charAt(i)) {
vowel = true;
}
}
if (vowel) {
if (v == 0) {
p1 = new Elem(word, w1.head);
w1.head = p1;
v++;
}
else {
Elem q1 = p1;
p1 = new Elem(word, null);
q1.setNext(p1);
}
}
else {
if (c == 0) {
p2 = new Elem(word, w2.head);
w2.head = p2;
c++;
}
else {
Elem q2 = p2;
p2 = new Elem(word, null);
q2.setNext(p2);
}
}
p = p.getNext();
}
WordSet [] vowelDivide = new WordSet[2];
vowelDivide[0].setHead(w1.head);
vowelDivide[1].setHead(w2.head);
return vowelDivide;
}