private ILoginVisitor <string> loginVisitor; //The visitor public TeacherLogIn() { this.username = new NoneLogin(); //Username and password are none by default to avoid null's this.password = new NoneLogin(); this.loginVisitor = new LogInInformationStoreVisitor <string>(); this.InitializeComponent(); }
//When the user clicks on the login button, this method gets activated private void LogInButtonClick(object sender, RoutedEventArgs e) { username = new SomeUsernameLogin(UsernameTypeBox.Text.ToString()); //typed in username gets stored password = new SomePasswordLogin(passwordBox.Password.ToString()); //typed in password gets stored username.VisitTheLoginInformation(loginVisitor); //visitor visits the username password.VisitTheLoginInformation(loginVisitor); //visitor visits the password CheckIfLogInIsCorrect(); //the user information gets checked }
//Stores password in array public void OnPassword(IUserNameAndPasswordVisit <string> typedInPassword) { usernameAndPassword[1] = typedInPassword; }
//Stores username in array public void OnUsername(IUserNameAndPasswordVisit <string> typedInUsername) { usernameAndPassword[0] = typedInUsername; }