State.java
package ch.hslu.exercises.sw12.ex7;
public enum State {
Z0 {
@Override
State next(Character c) {
if (c == '0') {
return Z1;
} else {
return Illegal;
}
}
},
Z1 {
@Override
State next(Character c) {
if (c == '1') {
return Z2;
} else {
return Illegal;
}
}
},
Z2 {
@Override
State next(Character c) {
if (c == '1') {
return Z3;
} else if (c == '0') {
return Z4;
} else {
return Illegal;
}
}
},
Z3 {
@Override
State next(Character c) {
if (c == '1') {
return Z2;
} else {
return Illegal;
}
}
},
Z4 {
@Override
State next(Character c) {
if (c == '1') {
return Z2;
} else {
return Illegal;
}
}
},
Illegal {
@Override
State next(Character c) {
return Illegal;
}
};
abstract State next(Character c);
}