Kaynağa Gözat

fixed all tests

thulasi 6 yıl önce
ebeveyn
işleme
283e6967a9

+ 7
- 10
src/main/java/HamletParser.java Dosyayı Görüntüle

37
     }
37
     }
38
 
38
 
39
     private Matcher matchingwords(String regex){
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
         return  matcher;
42
         return  matcher;
43
     }
43
     }
44
 
44
 
45
     public void changeHamletToLeon() {
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
     public void changeHoratioToTariq() {
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
     public boolean findHoratio() {
56
     public boolean findHoratio() {

+ 0
- 0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst Dosyayı Görüntüle


+ 1
- 0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst Dosyayı Görüntüle

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