1 package ch.hslu.exercises.sw12.ex7; 2 3 public enum State { 4 Z0 { 5 @Override 6 State next(Character c) { 7 if (c == '0') { 8 return Z1; 9 } else { 10 return Illegal; 11 } 12 } 13 }, 14 Z1 { 15 @Override 16 State next(Character c) { 17 if (c == '1') { 18 return Z2; 19 } else { 20 return Illegal; 21 } 22 } 23 }, 24 Z2 { 25 @Override 26 State next(Character c) { 27 if (c == '1') { 28 return Z3; 29 } else if (c == '0') { 30 return Z4; 31 } else { 32 return Illegal; 33 } 34 } 35 }, 36 Z3 { 37 @Override 38 State next(Character c) { 39 if (c == '1') { 40 return Z2; 41 } else { 42 return Illegal; 43 } 44 } 45 }, 46 Z4 { 47 @Override 48 State next(Character c) { 49 if (c == '1') { 50 return Z2; 51 } else { 52 return Illegal; 53 } 54 } 55 }, 56 Illegal { 57 @Override 58 State next(Character c) { 59 return Illegal; 60 } 61 }; 62 63 abstract State next(Character c); 64 }