public static void LoginExercise(string[] args) { LoginContext ctx = new LoginContext(); NewLogin login = new NewLogin(ctx); ctx.Init(login); ctx.pressedLogin("123"); // failed ctx.pressedLogin("1234"); // failed ctx.pressedLogin("12345"); // now succeed ctx.pressedLogin("4444"); // do nothing ctx.pressedRestart(); // Restart to new login now we should have 3 tries again. ctx.pressedLogin("123"); // failed ctx.pressedLogin("1234"); // failed ctx.pressedLogin("123"); // failed ctx.pressedLogin("1234"); // Locked ctx.pressedRestart(); // Restart ctx.pressedLogin("123"); // Failed ctx.pressedRestart(); // Restart }
protected LoginBase(LoginContext ctx) { this.ctx = ctx; }
public LoginSucceed(LoginContext ctx) : base(ctx) { }
public NewLogin(LoginContext ctx) : base(ctx) { }
public LoginFailed(LoginContext ctx) : base(ctx) { counter = 1; }
public Locked(LoginContext ctx) : base(ctx) { }