|
|
@@ -1,6 +1,8 @@
|
|
1
|
1
|
package rocks.zipcode;
|
|
2
|
2
|
|
|
3
|
3
|
import java.io.IOException;
|
|
|
4
|
+import java.util.regex.Matcher;
|
|
|
5
|
+import java.util.regex.Pattern;
|
|
4
|
6
|
|
|
5
|
7
|
/**
|
|
6
|
8
|
* @author leon on 16/11/2018.
|
|
|
@@ -12,9 +14,12 @@ public class AlphaCharDocument extends Document {
|
|
12
|
14
|
|
|
13
|
15
|
@Override
|
|
14
|
16
|
public void write(String contentToBeWritten) {
|
|
|
17
|
+ if (isAlpha(contentToBeWritten)) {
|
|
|
18
|
+ super.write(contentToBeWritten);
|
|
|
19
|
+ } else throw new IllegalArgumentException();
|
|
15
|
20
|
}
|
|
16
|
21
|
|
|
17
|
22
|
private Boolean isAlpha(String s) {
|
|
18
|
|
- return null;
|
|
|
23
|
+ return s.matches("[a-zA-Z\\s]*");
|
|
19
|
24
|
}
|
|
20
|
25
|
}
|