|
@@ -1,6 +1,8 @@
|
1
|
1
|
import java.io.File;
|
2
|
2
|
import java.io.IOException;
|
3
|
3
|
import java.util.Scanner;
|
|
4
|
+import java.util.regex.Matcher;
|
|
5
|
+import java.util.regex.Pattern;
|
4
|
6
|
|
5
|
7
|
/**
|
6
|
8
|
* Created by thook on 10/7/15.
|
|
@@ -36,4 +38,38 @@ public class HamletParser {
|
36
|
38
|
return hamletData;
|
37
|
39
|
}
|
38
|
40
|
|
|
41
|
+ public void hamletToLeon(){
|
|
42
|
+ Pattern pattern = Pattern.compile("Hamlet", Pattern.CASE_INSENSITIVE);
|
|
43
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
44
|
+ this.hamletData = matcher.replaceAll("Leon");
|
|
45
|
+
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ public void horatioToTariq() {
|
|
49
|
+ Pattern pattern = Pattern.compile("Horatio", Pattern.CASE_INSENSITIVE);
|
|
50
|
+ Matcher matcher = pattern.matcher(hamletData);
|
|
51
|
+ this.hamletData = matcher.replaceAll("Tariq");
|
|
52
|
+ }
|
|
53
|
+
|
|
54
|
+ public boolean findHoratio() {
|
|
55
|
+ final Scanner sc = new Scanner(hamletData);
|
|
56
|
+ while(sc.hasNextLine()){
|
|
57
|
+ final String fileLine = sc.nextLine();
|
|
58
|
+ if (fileLine.contains("Horatio")) {
|
|
59
|
+ return true;
|
|
60
|
+ }
|
|
61
|
+ }
|
|
62
|
+ return false;
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ public boolean findHamlet() {
|
|
66
|
+ final Scanner sc = new Scanner(hamletData);
|
|
67
|
+ while(sc.hasNextLine()){
|
|
68
|
+ final String fileLine = sc.nextLine();
|
|
69
|
+ if (fileLine.contains("Hamlet")) {
|
|
70
|
+ return true;
|
|
71
|
+ }
|
|
72
|
+ }
|
|
73
|
+ return false;
|
|
74
|
+ }
|
39
|
75
|
}
|