1 package ch.hslu.exercises.sw12.ex7;
2
3 public final class Language {
4
5 public static boolean isWordLanguage(final String string) {
6 char[] chars = string.toCharArray();
7
8 State state = State.Z0;
9 for (char c : chars) {
10 state = state.next(c);
11 if (state == null) {
12 return false;
13 }
14 }
15 return state == State.Z4 | state == State.Z1;
16 }
17
18 public static boolean isWordLanguageRegex(final String string) {
19 return string.matches("^0(1(11)*0)*");
20 }
21
22 }