-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjaws.java
More file actions
85 lines (61 loc) · 1.58 KB
/
Copy pathjaws.java
File metadata and controls
85 lines (61 loc) · 1.58 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.*;
public class jaws {
public static void main(String[] args)
throws FileNotFoundException{
String fileName = "jawsScript.txt";
PrintStream outToFile = new PrintStream(new File("SouthernJaws.txt"));
Scanner fromFile = new Scanner(new File(fileName));
while(fromFile.hasNext())
{
String word = fromFile.next();
word = word.replaceAll("\\p{Punct}", ""); // gets rid of all punct.
System.out.println(word);
String newWords = southAccent(word);
for(int i = 0; i < newWords.length(); i++)
{
outToFile.print(newWords.charAt(i));
}
outToFile.println();
System.out.println(newWords);
}
outToFile.close();
System.out.print("Done");
}
public static String southAccent(String word)
{
String newWord = "";
for(int i = 0; i < word.length(); i++)
{
char c = word.charAt(i);
if(word.charAt(0) == 'r' || word.charAt(0) == 'R')
{
newWord += c;
}
else if(c == 'r' || c == 'R' && isVowel(word.charAt(i - 1)))
{
newWord += 'h';
}
else
{
newWord += c;
}
}
// if(word.charAt(word.length() - 1) == 'a')
// newWord += "r";
if(newWord.equals("very"))
newWord = "wicked";
return newWord;
}
public static boolean isVowel(char c)
{
char[] vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
for(int i = 0; i < vowels.length; i++)
{
if(vowels[i] == c)
return true;
}
return false;
}
}