| 123456789101112131415161718192021222324252627 |
- package rocks.zipcode;
-
- import java.io.IOException;
-
- /**
- * @author leon on 16/11/2018.
- */
- public class AlphaCharDocument extends Document {
- public AlphaCharDocument(String fileName) throws IOException {
- super(fileName);
- }
-
- @Override
- public void write(String contentToBeWritten) {
- if (isAlpha(contentToBeWritten)){
- super.write(contentToBeWritten);
-
- }else{
- throw new IllegalArgumentException();
- }
- }
-
- private Boolean isAlpha(String s) {
- return (s.matches("[a-zA-z ]+"));
- }
- }
|