Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Implements the Login interface. Defines a list-based set of accounts.
- */
- package login.impl;
- import login.*;
- import java.util.*;
- public class InMemoryLogin implements Login
- {
- public ArrayList<Account> account;
- /**
- * Adds a given person's login credentials to the list.
- * @param login The username associated to the account.
- * @param password The password associated to the account.
- * @param email The email associated to the account.
- */
- public void add(String login, String password, String email)
- {
- if(account == null)
- account = new ArrayList<Account>();
- Account a = new Account(login, password, email);
- account.add(a);
- }
- /**
- * Checks the presence of a given account in the list. Returns it if present.
- * @param login The username associated to the account.
- * @param password The password associated to the account.
- * @return The account associated to the given access credentials, if present.
- */
- public Account login(String login, String password)
- {
- if(account == null)
- return null;
- for(int i = 0; i < account.size(); i++)
- {
- if(account.get(i).getLogin().equals(login) && account.get(i).getPassword().equals(password))
- return account.get(i);
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement