Ver código fonte

fixed all tests

thulasi 6 anos atrás
pai
commit
283e6967a9

+ 7
- 10
src/main/java/HamletParser.java Ver arquivo

@@ -37,23 +37,20 @@ public class HamletParser {
37 37
     }
38 38
 
39 39
     private Matcher matchingwords(String regex){
40
-        Pattern pattern = Pattern.compile(regex);
41
-        Matcher matcher = pattern.matcher(this.hamletData.toLowerCase());
40
+        Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
41
+        Matcher matcher = pattern.matcher(this.hamletData);
42 42
         return  matcher;
43 43
     }
44 44
 
45 45
     public void changeHamletToLeon() {
46
-        if(findHamlet()) {
47
-            Matcher matcher = matchingwords("Hamlet");
48
-            matcher.replaceAll("Leon");
49
-        }
46
+
47
+        Matcher matcher = matchingwords("hamlet");
48
+        hamletData = matcher.replaceAll("Leon");
50 49
     }
51 50
 
52 51
     public void changeHoratioToTariq() {
53
-        if(findHamlet()) {
54
-            Matcher matcher = matchingwords("Horatio");
55
-            matcher.replaceAll("Tariq");
56
-        }
52
+        Matcher matcher = matchingwords("horatio");
53
+        hamletData = matcher.replaceAll("Tariq");
57 54
     }
58 55
 
59 56
     public boolean findHoratio() {

+ 0
- 0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst Ver arquivo


+ 1
- 0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst Ver arquivo

@@ -0,0 +1 @@
1
+/Users/thulasipuppala/Labs/Week 6/ZCW-Regex-Hamlet-Parser/src/main/java/HamletParser.java