|
@@ -1,5 +1,6 @@
|
1
|
1
|
import java.io.File;
|
2
|
2
|
import java.io.IOException;
|
|
3
|
+import java.util.ArrayList;
|
3
|
4
|
import java.util.Scanner;
|
4
|
5
|
|
5
|
6
|
/**
|
|
@@ -8,6 +9,7 @@ import java.util.Scanner;
|
8
|
9
|
public class HamletParser {
|
9
|
10
|
|
10
|
11
|
private String hamletData;
|
|
12
|
+ String[] wordArr;
|
11
|
13
|
|
12
|
14
|
public HamletParser(){
|
13
|
15
|
this.hamletData = loadFile();
|
|
@@ -21,6 +23,12 @@ public class HamletParser {
|
21
|
23
|
try(Scanner scanner = new Scanner(file)){
|
22
|
24
|
while(scanner.hasNextLine()){
|
23
|
25
|
String line = scanner.nextLine();
|
|
26
|
+ if (isHamletOrHoratio(line)){
|
|
27
|
+ wordArr = line.split(" ");
|
|
28
|
+ }
|
|
29
|
+ //loop through line for next
|
|
30
|
+ //if next matches Hamlet, replace with Leon
|
|
31
|
+ //if next matches Horatio, replace with Tariq
|
24
|
32
|
result.append(line).append("\n");
|
25
|
33
|
}
|
26
|
34
|
|
|
@@ -36,4 +44,12 @@ public class HamletParser {
|
36
|
44
|
return hamletData;
|
37
|
45
|
}
|
38
|
46
|
|
|
47
|
+ public boolean isHamletOrHoratio(String line){
|
|
48
|
+ if (line.toLowerCase().matches("hamlet") || line.toLowerCase().matches("horatio")){
|
|
49
|
+ return true;
|
|
50
|
+ } else {
|
|
51
|
+ return false;
|
|
52
|
+ }
|
|
53
|
+ }
|
|
54
|
+
|
39
|
55
|
}
|