LLD - Behavioral Design Patterns — Part 1
In the following State pattern code, what is the main issue causing incorrect behavior?
interface State {
void handle(Context c);
}
class Context {
State state;
void request() {
state.handle(this);
}
}
class ConcreteStateA implements State {
void handle(Context c) {
// Missing state transition
System.out.println("State A handling");
}
}
Context ctx = new Context();
ctx.state = new ConcreteStateA();
ctx.request();
ctx.request();
