mpierse před 7 roky
rodič
revize
1597bc795b

+ 9
- 2
src/main/java/rocks/zipcode/NumericCharDocument.java Zobrazit soubor

@@ -12,9 +12,16 @@ public class NumericCharDocument extends Document {
12 12
 
13 13
     @Override
14 14
     public void write(String contentToBeWritten) {
15
+        try {
16
+            isNumeric(contentToBeWritten);
17
+            super.write(contentToBeWritten);
18
+        } catch (IOException e) {
19
+            e.printStackTrace();
20
+        }
15 21
     }
16 22
 
17
-    private Boolean isNumeric(String s) {
18
-        return null;
23
+    private void isNumeric(String s) throws IOException{
24
+        if(!s.matches("[0-9\\s]*"))
25
+            throw new IllegalArgumentException();
19 26
     }
20 27
 }

+ 9
- 2
src/main/java/rocks/zipcode/SpecialCharDocument.java Zobrazit soubor

@@ -12,9 +12,16 @@ public class SpecialCharDocument extends Document {
12 12
 
13 13
     @Override
14 14
     public void write(String contentToBeWritten) {
15
+        try {
16
+            isSpecialCharacters(contentToBeWritten);
17
+            super.write(contentToBeWritten);
18
+        } catch (IOException e) {
19
+            e.printStackTrace();
20
+        }
15 21
     }
16 22
 
17
-    private Boolean isSpecialCharacters(String s) {
18
-        return null;
23
+    private void isSpecialCharacters(String s) throws IOException {
24
+        if(!s.matches("[\\W_]*"))
25
+            throw new IllegalArgumentException();
19 26
     }
20 27
 }